Or if you don't feel like thinking, you could try a bogo approach:
outputsCode:#include <iostream> #include <vector> #include <set> #include <algorithm> #include <iterator> #include <ctime> #include <cstdlib> typedef std::vector<char> line; char binary_random_generator() { return std::rand()%2; } int main() { std::srand(std::time(0)); std::set<line> a_set; line a_line(5); int fail_counter = 0; while(fail_counter < 1000) { std::generate_n(a_line.begin(), 5, binary_random_generator); if(a_set.insert(a_line).second) { fail_counter = 0; } else { ++fail_counter; } } std::cout << "There are " << a_set.size() << " Posibilities." << std::endl; }
Disclaimer: Bogo is of factorial complexity.Code:There are 32 Posibilities.




Reply With Quote