RosettaCodeData/Task/Nim-game/Dyalect/nim-game.dyalect
2023-07-01 13:44:08 -04:00

20 lines
511 B
Text

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.")