+ 2

Matchstick game(logic)

you have total 21 sticks. one player can pick 1,2,3or 4 sticks. user wii start the game. the player who have to pick the last stick will lose the game. make sure computer must always win. write a program for this code in various languages.

14th Jan 2018, 5:01 AM
Rahul Jain
Rahul Jain - avatar
6 Réponses
+ 5
if it is your turn, at the end good numbers are 2,3,4,5 so the other one should have 6 to achieve that, good numbers for you are 7,8,9,10 so the other should have 11 good numbers for you 12,12,14,15 the other should have 16 good numbers for you 17,18,19,20 the other should have 21 The Beginner is always the looser The other takes (sticks mod 5 ) -1 @rjprince is the same rule: other took + youtook is always 5.
14th Jan 2018, 6:44 AM
Oma Falk
Oma Falk - avatar
14th Jan 2018, 6:59 AM
Nicky
Nicky - avatar
14th Jan 2018, 7:17 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 4
14th Jan 2018, 5:23 AM
Rahul Jain
Rahul Jain - avatar
+ 2
14th Jan 2018, 7:31 AM
Oleg «0RaKlE19» Kolodka
Oleg «0RaKlE19» Kolodka - avatar
+ 2
I want this code in php or JS.
24th Aug 2020, 12:55 PM
Manender Dutt
Manender Dutt - avatar