The Stones

The Stones

English JA RU
Your backpack with all of the equipment and treasures got real heavy, but you welcomed this burden - with this money you'll be able to compensate for the broken ships and celebrate the successfulness of the expedition. Of course, for this you first need to get home, but your gut has been telling you that you are gonna make it.

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 played properly and both players use the best strategy).
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.

Input: An amount of the rocks in the pile and the numbers you can take from it.

Output: Winner's number (1 or 2)


stones(17, [1, 3, 4]) == 2
stones(17, [1, 3, 4, 6, 9]) == 1

How it is used: For the game AI development.

Precondition :
2 players - 1 winner

Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission