blob: 05c25dbb584cfe47965b0b150c684e2cacd4d19b (
plain)
| 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
 | val computer: int = random(1, 10);
var tries: int = 0;
var correct: bool = false;
while !correct {
    print("\nPick a number between 1 and 10: ");
    val human: int = parse_int(readln());
    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.");
    }
    
    tries = tries + 1;
}
println("\nIt took you ", tries, " tries to guess correctly!");
 |