Browse files

add guess the number example

  • Loading branch information...
1 parent 863c3a3 commit 0571be5b078495911379b90b079d660cd29cdbcb @bakkdoor committed Nov 14, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 examples/guess_number.fy
View
18 examples/guess_number.fy
@@ -0,0 +1,18 @@
+max = 10
+secret_number = max random
+counter = 1
+
+loop: {
+ guess = Console readln: "Guess a number between 0 and #{max}: " to_i
+ if: (guess == secret_number) then: {
+ "You got it! It took you #{counter} attempts." println
+ break
+ } else: {
+ if: (guess < secret_number) then: {
+ "That's too low. Try again." println
+ } else: {
+ "That's too high. Try again." println
+ }
+ }
+ counter = counter + 1
+}

0 comments on commit 0571be5

Please sign in to comment.