Two rival trail scouts, Aiten and Bryn, keep watch over a ridge strung with n lit signal torches. Starting with Aiten, the scouts alternate turns. On a turn, the scout in motion must extinguish exactly 1, 2, or 3 of the torches that are still lit (it does not matter which physical torches are chosen, only how many remain lit afterward). A scout may never pass, and may never extinguish more torches than are currently lit. Whichever scout extinguishes the very last lit torch wins the watch. Both scouts play with perfect strategy from the very first move. Given the number of torches lit at the start, determine whether Aiten -- who always moves first -- can force a win no matter how well Bryn plays.
A single line containing one integer n, the number of torches lit at the start.
Print exactly one line containing the single word WIN if Aiten can force a win, or LOSE if Bryn can always force Aiten to lose, assuming both scouts play optimally.
Example 1
Input
4
Expected
LOSE
Explanation
With n = 4 torches lit, whatever Aiten extinguishes first (1, 2, or 3 torches), Bryn is left facing 3, 2, or 1 lit torches respectively, and in each case Bryn can extinguish all of them immediately and win. So no matter what Aiten does, Bryn can always force a win, and the output is LOSE.
Example 2
Input
5
Expected
WIN
Explanation
With n = 5, Aiten can extinguish exactly 1 torch, leaving 4 lit torches for Bryn to face -- the same losing position from Example 1. Whatever Bryn does next, Aiten can always answer so as to hand Bryn another losing count, eventually forcing the last torch to fall to Aiten. So Aiten can force a win, and the output is WIN.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →