diff options
author | Guillermo Ramos | 2012-04-02 20:48:33 +0200 |
---|---|---|
committer | Guillermo Ramos | 2012-04-02 20:48:33 +0200 |
commit | 8ae4691e677414843cf3a84d4327d303fe3e2f41 (patch) | |
tree | 6007373b702ece4100819606a82ecbae76ff1dd5 /io/guess.io | |
parent | fdd1e7abacd96d9bd49c13b2ecfcfe897546acae (diff) | |
download | 7l-8ae4691e677414843cf3a84d4327d303fe3e2f41.tar.gz |
[Io] Día 2
Diffstat (limited to 'io/guess.io')
-rw-r--r-- | io/guess.io | 26 |
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 |