summaryrefslogtreecommitdiff
path: root/io/guess.io
blob: 49ceeaacd19c278d151ca0d51bcf285d46685e0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
stdin := File standardInput
secret := Random value(1, 100) round
tries := 10
n := nil
newdiff := nil
diff := nil

"Guess the secret number between 1 and 100 :D" println

while (n != secret and tries > 0,
	write("You have ", tries, " tries left\nNumber? > ")
	n = stdin readLine asNumber

	newdiff = (secret - n) abs
	if (diff isNil) then (
		diff = newdiff
	) else (
		if (newdiff < diff, "Hotter", "Colder") println
		diff = newdiff
	)

	"" println
	tries = tries - 1
)

if (n == secret, "Correct!", "Epic fail!") println