Share your repls and programming experiences

← Back to all posts
First to 21 loses.

In this game you will be playing against an AI. You can raise the counter by 1, 2, or 3. Then the AI will go. If the other person reaches 20, you basically lose.

EzekielJeske (3)

Super simple. Anyone could do it. The "AI" just always adds whatever number brings the total up to a multiple of four, which makes it impossible to beat.

gantr833 (161)

@EzekielJeske: That was the trick I used at school.

joshwood (117)

You should let the AI go first sometimes... just to make it fair. ;)

Fun program!

gantr833 (161)

@joshwood I am thinking of asking the user if they or the AI should go first. Thanks for the feedback!

themaka (186)

Very nice! I remember playing this in school as a kid (I was a nerd).

georgina3 (8)

i know how you can't win when you type 1 al types 3 when you type 2 al types 2 when you type 3 al types 1

Myles123456 (0)

this is really good actually i just always lose it seems like

TuanNguyen8 (0)

My teacher teached me a trick to play this at my extra class when in was a kid. The objective is to hit n(the number that if u hit u will lose)-1 first. U have to go first if (n-1)/(k(the max value that u can add)+1)=m>0. Then u will add m. Else u have to let the opponent go first. Then on the other turns, the sum of your and your opponents point have to equal to m. But in this case (21-1)/(4+1)=0 so u have to let the bot go first but u cant do that because “0” is an invalid value so u cant win this.
But this is very good tho!!!
Good job.

Pythonier (314)

@TuanNguyen8 Wow! that is really complex. I found another trick that works: I just added the a number that would make their and my number equal to 4.

PYer (3573)

@epicman702 It is impossible to beat

sthomason1 (1)

@epicman702 If you look closely, there's not even any code for the player winning

davwheat (22)

The amazing game of NIM.

Zavexeon (1071)

This game is evil.

Pure evil.

+1 though.