Skip to content

Instantly share code, notes, and snippets.

@lastday154
Created November 25, 2017 00:43
Show Gist options
  • Select an option

  • Save lastday154/952a364b5a6459d83c279129dbed4972 to your computer and use it in GitHub Desktop.

Select an option

Save lastday154/952a364b5a6459d83c279129dbed4972 to your computer and use it in GitHub Desktop.
Tournament Honestbee
#include <iostream>
#include <vector>
using namespace std;
int tour(int num_kid, int x)
{
vector<int> v;
for (int i=0; i<num_kid; i++) {
v.push_back(i);
}
while(v.size() != 1)
{
int n = v.size();
int pos = x%n - 1;
if (pos < 0)
{
pos = n-1;
}
v.erase(v.begin() + pos);
}
return v[0];
}
int main()
{
cout<<tour(5,4);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment