Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Bulls-and-cows/MiniScript/bulls-and-cows.mini
Normal file
26
Task/Bulls-and-cows/MiniScript/bulls-and-cows.mini
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
secret = range(1,9)
|
||||
secret.shuffle
|
||||
secret = secret[:4].join("")
|
||||
|
||||
while true
|
||||
guess = input("Your guess? ").split("")
|
||||
if guess.len != 4 then
|
||||
print "Please enter 4 numbers, with no spaces."
|
||||
continue
|
||||
end if
|
||||
bulls = 0
|
||||
cows = 0
|
||||
for i in guess.indexes
|
||||
if secret[i] == guess[i] then
|
||||
bulls = bulls + 1
|
||||
else if secret.indexOf(guess[i]) != null then
|
||||
cows = cows + 1
|
||||
end if
|
||||
end for
|
||||
if bulls == 4 then
|
||||
print "You got it! Great job!"
|
||||
break
|
||||
end if
|
||||
print "You score " + bulls + " bull" + "s"*(bulls!=1) +
|
||||
" and " + cows + " cow" + "s"*(cows!=1) + "."
|
||||
end while
|
||||
Loading…
Add table
Add a link
Reference in a new issue