Skip to content

Instantly share code, notes, and snippets.

@itsPG
Created August 28, 2013 08:52
Show Gist options
  • Save itsPG/6363748 to your computer and use it in GitHub Desktop.
Save itsPG/6363748 to your computer and use it in GitHub Desktop.
by PG @ SENSE Lab
#include <iostream>
#include <algorithm>
using namespace std;
int flower[] = {1,2,3,4,5,6,7,8};
bool check_pick()
{
for (int i = 3; i < 8; i++)
if (flower[i] > flower[0] && flower[i] > flower[1] && flower[i] > flower[2])
return flower[i] == 8;
return false;
}
int main()
{
int total_times = 0, success_time = 0;
while (1)
{
++total_times;
if (check_pick()) success_time++;
if (!next_permutation(flower, flower + 8)) break;
}
cout << success_time << " / " << total_times << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment