Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Nim-game/11l/nim-game.11l
Normal file
26
Task/Nim-game/11l/nim-game.11l
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
V tokens = 12
|
||||
|
||||
F getTokens(curTokens) -> N
|
||||
print(‘How many tokens would you like to take? ’, end' ‘’)
|
||||
V take = Int(input())
|
||||
|
||||
I (take < 1 | take > 3)
|
||||
print("Number must be between 1 and 3.\n")
|
||||
getTokens(curTokens)
|
||||
R
|
||||
|
||||
:tokens = curTokens - take
|
||||
print(‘You take #. tokens.’.format(take))
|
||||
print("#. tokens remaining.\n".format(:tokens))
|
||||
|
||||
F compTurn(curTokens)
|
||||
V take = curTokens % 4
|
||||
:tokens = curTokens - take
|
||||
print(‘Computer takes #. tokens.’.format(take))
|
||||
print("#. tokens remaining.\n".format(:tokens))
|
||||
|
||||
L tokens > 0
|
||||
getTokens(tokens)
|
||||
compTurn(tokens)
|
||||
|
||||
print(‘Computer wins!’)
|
||||
Loading…
Add table
Add a link
Reference in a new issue