Skip to content

Instantly share code, notes, and snippets.

@LordAro
Created February 18, 2015 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LordAro/a1173c39703497b5a8f5 to your computer and use it in GitHub Desktop.
Save LordAro/a1173c39703497b5a8f5 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <iostream>
int main()
{
std::vector<int> nums(10);
std::iota(nums.begin(), nums.end(), 1);
do {
if (std::accumulate(nums.begin() + 1, nums.end(), 0) == 46) {
for (const auto &i : nums) {
std::cout << i << " ";
}
std::cout << std::endl;
return 0;
}
} while(std::next_permutation(nums.begin(), nums.end()));
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment