Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,24 @@
# syntax: GAWK -f NIM_GAME.AWK
BEGIN {
tokens = 12
printf("Nim game - using %d tokens\n",tokens)
while (tokens > 0) {
for (;;) {
printf("how many tokens 1-3? ")
getline ans
if (ans ~ /^[123]$/) {
tokens -= ans
prn("player")
break
}
print("invalid input, try again")
}
tokens -= ans = tokens % 4
prn("computer")
}
print("computer wins")
exit(0)
}
function prn(who) {
printf("%s takes %d token%s; there are %d remaining\n",who,ans,(ans==1)?"":"s",tokens)
}