feat: add guessing example

This commit is contained in:
Matthieu Bessat 2022-05-16 11:02:04 +02:00
parent 547c5d0c63
commit 0ced372a77
3 changed files with 31 additions and 2 deletions

23
examples/guessing.ltor Normal file
View file

@ -0,0 +1,23 @@
set i to 0
set toGuess to random_int(0, 100)
while 1 do
set guessed to input_number()
if i > 20 then
# do you really want to continue?
break
end
if guessed = toGuess then
# success
print_ascii(83)
break
end
if guessed < toGuess then
# too low
print_ascii(76)
end
if guessed > toGuess then
# too high
print_ascii(72)
end
set i to i+1
end