# Try not to get the last piece, but with a twist!

This question has been bothering me for a while, and I have tried taking steps where I split the n # of sushi into even and odd, but I still can’t figure out a common algorithm to satisfy these cases.

The rules are as follows: 𝑛 pieces of tuna sashimi have been ordered, and each of the three participants
takes turns eating either 1, 3, or 5 pieces of sashimi. The person who eats the last piece of sashimi
must pay for the meal.
Describe an algorithm for determining how many pieces of sushi you should eat on any given turn to
avoid having to pay the bill. Assume that if there are two different moves which can make either the
previous player lose or the next player lose, the move which makes the next player lose is preferred.

#### Solutions Collecting From Web of "Try not to get the last piece, but with a twist!"

Assuming perfect play for all players A, B, and C, then we get the following (assuming itis A’s turn, followed by B, then C):

1 piece left: A loses

2 left: eat 1: B loses

3 left: eat 1: C loses

4 left: eat 3, B loses

5: 1 or 3: C

6: 5: B

7: 1 or 3 or 5: C

8: A loses no matter what

9: 1: B

10: 1: C

11: 3: B

12: 1 or 3: C

13: 5: B

14: 1 or 3 or 5: C

15: 1 or 3 or 5: A

and now we see that the pattern repeats every 7.

So, perfect play indicates that if the remainder of $n$ divided by $7$ is:

1: You lose no matter what

2: Eat 1 … B will lose

3: Eat 1 … C will lose

4: Eat 3 … B will lose

5: Eat 1 or 3 … C will lose

6: Eat 5 … B will lose

7: C will lose no matter what

So, if you start, you have a 1 in 7 chance of losing.