https://www.codingame.com/training/easy/smooth

Send your feedback or ask for help here!

Created by @JBM,validated by @bbb000bbbyyy,@Niako and @dbdr.

If you have any issues, feel free to ping them.

https://www.codingame.com/training/easy/smooth

Send your feedback or ask for help here!

Created by @JBM,validated by @bbb000bbbyyy,@Niako and @dbdr.

If you have any issues, feel free to ping them.

Does not untherstand the rules.

what is on the first line one of each fruit?

what is replaced by 3 bananas in the example?

2 Likes

@JBM do you think you could give an example of how this game would work with a higher starting number? im not sure if the game allows the same fruit to be used multiple times. Maybe i am overthinking this but im having a really hard time understanding the game and its stopping me from being able to solve the challenge. Can you only win at the end of a turn with 1 fruit remaining and otherwise if the number is not divisible by 5||3||2 your opponent wins? Appreciate you, thanks.

I have solved this puzzle and maybe I can help you.

Yes, it does. To example to win with f=9 you have to replace two times with oranges and then with one watermelon.

Yes, because as your last action to win, you have to replace one fruit with one watermelon.

I was also a little confused by the statement at the beginning too. To say it a bit more mathematical: In every game turn (with n fruits) you can replace the fruits by n/5 fruits (bananas), n/3 fruits (oranges), n/2 fruits (apples) or n fruits (watermelon). If n is not divisible by 5, 3 or 2 and n is not 1, you lost.

Except by the last action, itâ€™s not important, which fruit is on the table, only how much.

I hope I could help you.

7 Likes

The english description should really be revised, preferably by someone who speaks the language and is up for the task. Itâ€™s close to impossible to comprehend as is.

6 Likes

Rules donâ€™t explicitly forbid to replace any number of fruits with watermelons.

So if there are 7 fruits, Ham can replace them with 7 watermelons.

In turn, Ming can replace them with 7 watermelons again, and basically game never ends.

Thatâ€™s true. But your task is to find out if they can win the game playing optimally. And replacing a number of a number of fruits > 1 by watermelons is never optimally.

1 Like

Replacing 7 fruits with 7 watermelons is optimal, because otherwise player loses.

Basically, thatâ€™s the only legit move in this case.

What I meant is that it doesnâ€™t matter in this case: You can replace it and the game never ends (which is equal to losing the game). So if you have 7 fruits left, you will lose in either case.

So yes, the rules donâ€™t forbid replacing any number of fruits with watermelons, but that doesnâ€™t change the problem.

Just to say, for any new coder trying this exercice, and struggling with the statement: read the previous posts from @ItsAFeature, whose explanations greatly help me to understand the statement.

Iâ€™ll add to this.

The game isnâ€™t about if player 1 wins. It is about if any player wins. Once you understand this, this puzzle becomes very easy.