Skip to content

Instantly share code, notes, and snippets.

@kg86
Created August 31, 2014 08:27
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 kg86/81b9109370c182cbd6a6 to your computer and use it in GitHub Desktop.
Save kg86/81b9109370c182cbd6a6 to your computer and use it in GitHub Desktop.
class BallAndHats
{
public:
int getHat(string hats, int numSwaps)
{
int idx = hats.find("o");
if (numSwaps == 0) return idx;
return (idx + (numSwaps % 2)) % 2;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment