After leaving the room with a vault, you've headed toward the dungeon. What you've seen next, turned down your optimism a few notches - the two skeletons laid right behind the entrance to the dungeon. Everything in their appearance indicated that they were the treasure hunters and, judging by the pallor of the bones sticking out of the pants and sleeves, they have laid here for many years. But how did they die?
"Сlick ..." - a barely audible sound of the dungeon door closing. You immediately rushed to it, but it was too late. Of course, it has no keyhole, and no other suggestions that it can be opened, for that matter. You tried to kick it down but it was too strong. Well, if you aren't planning to keep company to those two skeletons and starve to death, you have no choice but to find a way out. Perhaps you can find something useful near the skeletons - they should be examined more closely.
Approaching them, you've heard a voice coming out of nowhere: "... finish ... the game ...". There were only three options: either there was someone alive in the castle, or these were the ghosts that haunted it, or you've started to lose your mind and it was the first hallucination. Nope of those options has been too encouraging, but there were no way back. Finish the game and keep looking for Hypercube.
You most likely know the game where two players are in turn taking from a pile from 1 to 3 stones, and loses the one who took the last stone. We'll slightly generalize this task. Let's assume that both players can take not 1, 2, 3 stones, but k1, k2, …, km of stones. Here we are interested which player wins under the right circumstances (the game...
As the input you will get the number of stones in the pile at the beginning of the game and an amounts of stones you can take from pile at each move. For example - (10, [1, 2, 3]).
If the current amount of the stones in the pile is lower than lowest number in the "moves" list or equal to it - current player takes them all and lose.