I am an idiot

This commit is contained in:
PoliEcho 2024-12-15 13:06:29 +01:00
parent 97cb3b6639
commit f830923804
2 changed files with 0 additions and 29 deletions

View File

@ -3,35 +3,6 @@
#include <iostream>
#include <vector>
// this is defenitely my code
void heapPermutation(std::vector<char> &a, int size,
std::vector<std::vector<char>> &results) {
if (size == 1) {
results.push_back(a); // Store the current permutation
return;
}
for (int i = 0; i < size; i++) {
heapPermutation(a, size - 1, results); // Recur with reduced size
// If size is odd, swap the first element with the last element
if (size % 2 == 1) {
std::swap(a[0], a[size - 1]);
} else { // If size is even, swap the current element with the last element
std::swap(a[i], a[size - 1]);
}
}
}
std::vector<std::vector<char>>
generatePermutations(const std::vector<char> &input) {
std::vector<char> chars = input; // Create a mutable copy of input
std::vector<std::vector<char>> results; // To store all permutations
heapPermutation(chars, chars.size(), results); // Generate permutations
return results; // Return all permutations
}
// end of defenitely my code
int main() {
std::ifstream inputfile("input");
std::string input;

0
day8/day.cpp Normal file
View File