Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Nim-game/Julia/nim-game.julia
Normal file
22
Task/Nim-game/Julia/nim-game.julia
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function nimgame()
|
||||
tcount = 12
|
||||
takenum = 0
|
||||
while true
|
||||
while true
|
||||
permitted = collect(1:min(3,tcount))
|
||||
println("$tcount tokens remain.\nHow many do you take ($permitted)? ")
|
||||
takenum = parse(Int, strip(readline(stdin)))
|
||||
if takenum in permitted
|
||||
break
|
||||
end
|
||||
end
|
||||
tcount -= 4
|
||||
println("Computer takes $(4 - takenum). There are $tcount tokens left.")
|
||||
if tcount < 1
|
||||
println("Computer wins as expected.")
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
nimgame()
|
||||
Loading…
Add table
Add a link
Reference in a new issue