Created
April 1, 2014 13:09
-
-
Save marionette-of-u/9913667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <fstream> | |
| #include <functional> | |
| #include <thread> | |
| #include <memory> | |
| #include <iostream> | |
| int main(){ | |
| std::ofstream ofile("bfe.hpp"); | |
| std::size_t size = 5; | |
| const char pattern_array[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_' }; | |
| std::unique_ptr<char[]> buffer(new char[size + 1]); | |
| std::function<void(int, int, char*, char*)> f = [&](int s, int depth, char *p, char *q){ | |
| if(depth == 0){ | |
| *(q + 1) = '\0'; | |
| for(std::size_t i = 0; i < sizeof(pattern_array); ++i){ | |
| *q = pattern_array[i]; | |
| ofile << p << ",\n"; | |
| } | |
| }else{ | |
| for(std::size_t i = 0; i < sizeof(pattern_array); ++i){ | |
| if(depth == s && i > 25){ break; } | |
| *q = pattern_array[i]; | |
| f(s, depth - 1, p, q + 1); | |
| } | |
| } | |
| }; | |
| for(std::size_t i = 1; i <= size; ++i){ | |
| f(i - 1, i - 1, buffer.get(), buffer.get()); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment