You are viewing a single comment's thread. Return to all comments →
string nimGame(const vector<int>& pile) { int XOR = 0, twoOrMore = 0; for (int x : pile) { XOR = XOR ^ x; if (x > 1) twoOrMore++; } if (twoOrMore > 1) return (XOR == 0) ? "Second" : "First"; else if (twoOrMore == 1) return "First"; else return (pile.size() % 2 == 0) ? "First" : "Second"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Misère Nim
You are viewing a single comment's thread. Return to all comments →