diff options
Diffstat (limited to 'two')
-rw-r--r-- | two/guess.rkt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/two/guess.rkt b/two/guess.rkt new file mode 100644 index 0000000..ab05056 --- /dev/null +++ b/two/guess.rkt @@ -0,0 +1,21 @@ +#lang racket + +(define lower 1) + +(define upper 100) + +(define (start n m) + (set! lower (min n m)) + (set! upper (max n m)) + (guess)) + +(define (guess) + (quotient (+ lower upper) 2)) + +(define (smaller) + (set! upper (max lower (sub1 (guess)))) + (guess)) + +(define (bigger) + (set! lower (min upper (add1 (guess)))) + (guess)) |