Skip to content

Instantly share code, notes, and snippets.

@mmasztalerczuk
Created November 1, 2016 20:44
Show Gist options
  • Save mmasztalerczuk/57b90e5893e7cc5aba11eae70b89ca44 to your computer and use it in GitHub Desktop.
Save mmasztalerczuk/57b90e5893e7cc5aba11eae70b89ca44 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<cstring>
using namespace std;
class ThueMorseGame
{
public:
string get(int n, int m)
{
int last = 0;
int i = 0;
while (i <= n)
{
if (__builtin_popcount(i)%2 == 1)
{
i += 1;
}
else
{
last = i;
i += m + 1;
}
}
return last == n ? "Bob" : "Alice";
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment