summaryrefslogtreecommitdiff
path: root/io/guess.io
diff options
context:
space:
mode:
Diffstat (limited to 'io/guess.io')
-rw-r--r--io/guess.io26
1 files changed, 26 insertions, 0 deletions
diff --git a/io/guess.io b/io/guess.io
new file mode 100644
index 0000000..49ceeaa
--- /dev/null
+++ b/io/guess.io
@@ -0,0 +1,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