Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -4,66 +4,66 @@ digits = #(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
|||
num = ""
|
||||
while num.count < numCount and digits.count > 0 do
|
||||
(
|
||||
local r = random 1 digits.count
|
||||
append num (digits[r] as string)
|
||||
deleteitem digits r
|
||||
local r = random 1 digits.count
|
||||
append num (digits[r] as string)
|
||||
deleteitem digits r
|
||||
)
|
||||
digits = undefined
|
||||
numGuesses = 0
|
||||
inf = "Rules: \n1. Choose only % unique digits in any combination"+\
|
||||
" (0 can't be used).\n2. Only positive integers are allowed."+\
|
||||
"\n3. For each digit that is in it's place, you get a bull,\n"+\
|
||||
"\tand for each digit that is not in it's place, you get a cow."+\
|
||||
"\n4. The game is won when your number matches the number I chose."+\
|
||||
"\n\nPress [esc] to quit the game.\n\n"
|
||||
" (0 can't be used).\n2. Only positive integers are allowed."+\
|
||||
"\n3. For each digit that is in it's place, you get a bull,\n"+\
|
||||
"\tand for each digit that is not in it's place, you get a cow."+\
|
||||
"\n4. The game is won when your number matches the number I chose."+\
|
||||
"\n\nPress [esc] to quit the game.\n\n"
|
||||
clearlistener()
|
||||
format inf num.count
|
||||
while not keyboard.escpressed do
|
||||
(
|
||||
local userVal = getkbvalue prompt:"\nEnter your number: "
|
||||
if (userVal as string) == num do
|
||||
(
|
||||
format "\nCorrect! The number is %. It took you % moves.\n" num numGuesses
|
||||
exit with OK
|
||||
)
|
||||
local bulls = 0
|
||||
local cows = 0
|
||||
local badInput = false
|
||||
case of
|
||||
(
|
||||
(classof userVal != integer):
|
||||
(
|
||||
format "\nThe number must be a positive integer.\n"
|
||||
badInput = true
|
||||
)
|
||||
((userVal as string).count != num.count):
|
||||
(
|
||||
format "\nThe number must have % digits.\n" num.count
|
||||
badInput = true
|
||||
)
|
||||
((makeuniquearray (for i in 1 to (userVal as string).count \
|
||||
collect (userVal as string)[i])).count != (userVal as string).count):
|
||||
(
|
||||
format "\nThe number can only have unique digits.\n"
|
||||
badInput = true
|
||||
)
|
||||
)
|
||||
if not badInput do
|
||||
(
|
||||
userVal = userVal as string
|
||||
i = 1
|
||||
while i <= userVal.count do
|
||||
(
|
||||
for j = 1 to num.count do
|
||||
(
|
||||
if userVal[i] == num[j] do
|
||||
(
|
||||
if i == j then bulls += 1 else cows += 1
|
||||
)
|
||||
)
|
||||
i += 1
|
||||
)
|
||||
numGuesses += 1
|
||||
format "\nBulls: % Cows: %\n" bulls cows
|
||||
)
|
||||
local userVal = getkbvalue prompt:"\nEnter your number: "
|
||||
if (userVal as string) == num do
|
||||
(
|
||||
format "\nCorrect! The number is %. It took you % moves.\n" num numGuesses
|
||||
exit with OK
|
||||
)
|
||||
local bulls = 0
|
||||
local cows = 0
|
||||
local badInput = false
|
||||
case of
|
||||
(
|
||||
(classof userVal != integer):
|
||||
(
|
||||
format "\nThe number must be a positive integer.\n"
|
||||
badInput = true
|
||||
)
|
||||
((userVal as string).count != num.count):
|
||||
(
|
||||
format "\nThe number must have % digits.\n" num.count
|
||||
badInput = true
|
||||
)
|
||||
((makeuniquearray (for i in 1 to (userVal as string).count \
|
||||
collect (userVal as string)[i])).count != (userVal as string).count):
|
||||
(
|
||||
format "\nThe number can only have unique digits.\n"
|
||||
badInput = true
|
||||
)
|
||||
)
|
||||
if not badInput do
|
||||
(
|
||||
userVal = userVal as string
|
||||
i = 1
|
||||
while i <= userVal.count do
|
||||
(
|
||||
for j = 1 to num.count do
|
||||
(
|
||||
if userVal[i] == num[j] do
|
||||
(
|
||||
if i == j then bulls += 1 else cows += 1
|
||||
)
|
||||
)
|
||||
i += 1
|
||||
)
|
||||
numGuesses += 1
|
||||
format "\nBulls: % Cows: %\n" bulls cows
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Rules:
|
|||
1. Choose only 4 unique digits in any combination (0 can't be used).
|
||||
2. Only positive integers are allowed.
|
||||
3. For each digit that is in it's place, you get a bull,
|
||||
and for each digit that is not in it's place, you get a cow.
|
||||
and for each digit that is not in it's place, you get a cow.
|
||||
4. The game is won when your number matches the number I chose.
|
||||
|
||||
Press [esc] to quit the game.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue