Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Nim-game/Dyalect/nim-game.dyalect
Normal file
20
Task/Nim-game/Dyalect/nim-game.dyalect
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
print("There are twelve tokens.")
|
||||
print("You can take 1, 2, or 3 on your turn.")
|
||||
print("Whoever takes the last token wins.\n")
|
||||
|
||||
var tokens = 12
|
||||
while tokens > 0 {
|
||||
print("There are \(tokens) remaining.")
|
||||
print("How many do you take?")
|
||||
var playertake = Integer(readLine())
|
||||
|
||||
if playertake < 1 || playertake > 3 {
|
||||
print("1, 2, or 3 only.")
|
||||
} else {
|
||||
tokens -= playertake
|
||||
print("I take \(4 - playertake).")
|
||||
tokens -= (4 - playertake)
|
||||
}
|
||||
}
|
||||
|
||||
print("I win again.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue