Skip to content

Instantly share code, notes, and snippets.

@dstein64
Last active Jan 5, 2021
Embed
What would you like to do?
#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