Last active
September 9, 2022 04:55
-
-
Save AsifITk/10b8e9915bf4c90acc6dcbdeeeedd0d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ifAliceWon = (stone) => { | |
let res = []; | |
while (stone != 0) { | |
let suqare = []; | |
for (let i = 1; i <= stone; i++) { | |
let tem = i * i; | |
if (tem > stone) { | |
break; | |
} else { | |
suqare.push(tem); | |
} | |
} | |
if (suqare.length == 0) { | |
break; | |
} | |
stone = stone - suqare[suqare.length - 1]; | |
res.push(true); | |
} | |
if (res.length % 2 == 0) { | |
return false; | |
} | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment