You are viewing a single comment's thread. Return to all comments →
a C# solution:
public static string counterGame(long n) { bool louiseWins = false; while (n>1) { var log = Math.Log2(n); if ((log % 1) != 0) { log = Math.Floor(log); var next = (long)Math.Pow(2, log); n = (n - next); } else { n = n / 2; } louiseWins = !louiseWins; } return louiseWins ? "Louise" : "Richard"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
a C# solution: