Skip to content

Instantly share code, notes, and snippets.

@AsifITk
Last active September 9, 2022 04:55
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 AsifITk/10b8e9915bf4c90acc6dcbdeeeedd0d5 to your computer and use it in GitHub Desktop.
Save AsifITk/10b8e9915bf4c90acc6dcbdeeeedd0d5 to your computer and use it in GitHub Desktop.
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