Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
inclusiveRange = [1,100]
|
||||
lowRange = inclusiveRange.x
|
||||
maxRange = inclusiveRange.y
|
||||
guesses = 1
|
||||
inf = "Think of a number between % and % and I will try to guess it.\n" +\
|
||||
"Type -1 if the guess is less than your number,\n"+\
|
||||
"0 if the guess is correct, " +\
|
||||
"or 1 if it's too high.\nPress esc to exit.\n"
|
||||
clearListener()
|
||||
format inf (int lowRange) (int maxRange)
|
||||
while not keyboard.escpressed do
|
||||
(
|
||||
local chosen = ((lowRange + maxRange) / 2) as integer
|
||||
if lowRange == maxRange do format "\nHaving fun?"
|
||||
format "\nI choose %.\n" chosen
|
||||
local theAnswer = getKBValue prompt:"Answer? "
|
||||
case theAnswer of
|
||||
(
|
||||
(-1): (lowRange = chosen; guesses += 1)
|
||||
(0): (format "\nYay. I guessed your number after % %.\n" \
|
||||
guesses (if guesses == 1 then "try" else "tries")
|
||||
exit with OK)
|
||||
(1): (maxRange = chosen; guesses += 1)
|
||||
default: (format "\nI don't understand your input.")
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
OK
|
||||
Think of a number between 1 and 100 and I will try to guess it.
|
||||
Type -1 if the guess is less than your number,
|
||||
0 if the guess is correct, or 1 if it's too high.
|
||||
Press esc to exit.
|
||||
OK
|
||||
|
||||
I choose 50.
|
||||
Answer? -1
|
||||
I choose 75.
|
||||
Answer? -1
|
||||
I choose 87.
|
||||
Answer? 1
|
||||
I choose 81.
|
||||
Answer? -1
|
||||
I choose 84.
|
||||
Answer? -1
|
||||
I choose 85.
|
||||
Answer? 0
|
||||
Yay. I guessed your number after 6 tries.
|
||||
OK
|
||||
Loading…
Add table
Add a link
Reference in a new issue