Skip to content

Instantly share code, notes, and snippets.

@peter0749
Created February 26, 2019 06:22
Show Gist options
  • Save peter0749/305299b58d4c5b18dd68dd4a2743a5ed to your computer and use it in GitHub Desktop.
Save peter0749/305299b58d4c5b18dd68dd4a2743a5ed to your computer and use it in GitHub Desktop.
bored.cpp
#include <iostream>
#include <iomanip>
#include <algorithm>
int main(void) {
int a[9];
for (int i=0; i<9; ++i) a[i]=i+1;
do {
if (
a[0]-a[1]==a[2] &&
a[4]*a[5]==a[3] &&
a[6]+a[7]==a[8] &&
a[2]*a[5]==a[8]
) {
for (auto v:a) std::cout<<v<<' ';
std::cout<<std::endl;
}
} while(std::next_permutation(a,a+9));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment