Guess the number/With feedback (player): Difference between revisions

Added Arturo implementation
(Add AsciiDots solution)
(Added Arturo implementation)
Line 207:
end repeat
end run</lang>
 
=={{header|Arturo}}==
 
<lang rebol>print {:
Think of a number between 1 and 10 and wait for me to guess it.
On every guess of mine you should state whether the guess was
too high, too low, or equal to your number by typing h, l, or =
:}
 
rmin: 1
rmax: 10
 
while ø [
guess: random rmin rmax
print ["My guess is:" guess]
inputOk: false
while [not? inputOk][
hle: strip input "How did I do? (h)igh, (l)ow, (=): "
case [hle]
when? [="h"][
if? rmin =< dec guess [rmax: dec guess, inputOk: true]
else -> print "\tThat doesn't make any sense. I cannot find the number..."
]
when? [="l"][
if? (inc guess) =< rmax [rmin: inc guess, inputOk: true]
else -> print "\tThat doesn't make any sense. I cannot find the number..."
]
when? [="="][
print ""
print "Great! I found it! :)"
print "Thanks for keeping the score."
exit
]
else [
print "\tPlease, check your input; it doesn't appear to be correct!"
]
]
print ""
]</lang>
 
{{out}}
 
<pre>Think of a number between 1 and 10 and wait for me to guess it.
On every guess of mine you should state whether the guess was
too high, too low, or equal to your number by typing h, l, or =
 
My guess is: 7
How did I do? (h)igh, (l)ow, (=): h
 
My guess is: 1
How did I do? (h)igh, (l)ow, (=): fff
Please, check your input; it doesn't appear to be correct!
How did I do? (h)igh, (l)ow, (=): l
 
My guess is: 3
How did I do? (h)igh, (l)ow, (=): h
 
My guess is: 2
How did I do? (h)igh, (l)ow, (=): l
That doesn't make any sense. I cannot find the number...
How did I do? (h)igh, (l)ow, (=): =
 
Great! I found it! :)
Thanks for keeping the score.</pre>
 
=={{header|AsciiDots}}==
1,532

edits