diff options
| author | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-11 22:35:37 -0500 |
|---|---|---|
| committer | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-11 22:35:37 -0500 |
| commit | a6dc77aa4db8aec2593743f058d91d4fe572ab60 (patch) | |
| tree | 78582c5e8c64ea078c21cae93680348bdff8c8d2 /examples/guessing.sloth | |
| parent | 81c56242feb2951cece9b4876edb2e298548a5c1 (diff) | |
| download | sloth-a6dc77aa4db8aec2593743f058d91d4fe572ab60.tar.gz | |
Reformatted guessing.sloth
Diffstat (limited to 'examples/guessing.sloth')
| -rw-r--r-- | examples/guessing.sloth | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/examples/guessing.sloth b/examples/guessing.sloth index 830519b..1938269 100644 --- a/examples/guessing.sloth +++ b/examples/guessing.sloth @@ -1,14 +1,24 @@ val computer = random(1, 10); + var tries = 0; var correct = false; + while !correct { print("\nPick a number between 1 and 10: "); val human = parse_int(readln()); - if human == computer {println("You guessed the same number as me!"); - correct = true; + + if human == computer { + println("You guessed the same number as me!"); + correct = true; + } + + if human > computer { + println("Your guess was too high."); + } + + if human < computer { + println("Your guess was too low."); } - if human > computer {println("Your guess was too high.");} - if human < computer {println("Your guess was too low.");} tries = tries + 1; } |
