Last active
January 5, 2021 21:02
-
-
Save dstein64/c7b98d4846b4090aafb0274fe26f8d82 to your computer and use it in GitHub Desktop.
This file contains 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 <cassert> | |
#include <cstdlib> | |
#include <iostream> | |
#include <set> | |
#include <string> | |
#include <vector> | |
#include "revdoor.hpp" | |
using namespace std; | |
void print_set(const set<int>& s) { | |
set<int>::iterator it = s.begin(); | |
while (it != s.end()) { | |
if (it != s.begin()) cout << ","; | |
cout << *(it++); | |
} | |
cout << endl; | |
} | |
int main(int argc, char* argv[]) { | |
assert(argc == 3); | |
int n = stoi(argv[1]); | |
int t = stoi(argv[2]); | |
revdoor::combinations combs(n, t); | |
vector<int> init_state = combs.state(); | |
set<int> state(init_state.begin(), init_state.end()); | |
cout << "init: "; | |
print_set(state); | |
int in, out; | |
while (combs.step(&out, &in)) { | |
cout << "out: " << out << ", in: " << in << " state: "; | |
state.erase(out); | |
state.insert(in); | |
print_set(state); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment