From 74151dfc48e6be6dba11a0776af24c39eb9f592d Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 10 Mar 2018 03:29:02 +0000 Subject: Add net/ricketyspace/ror/two/guess.rkt. --- net/ricketyspace/ror/two/guess.rkt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 net/ricketyspace/ror/two/guess.rkt (limited to 'net') diff --git a/net/ricketyspace/ror/two/guess.rkt b/net/ricketyspace/ror/two/guess.rkt new file mode 100644 index 0000000..ab05056 --- /dev/null +++ b/net/ricketyspace/ror/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)) -- cgit v1.2.3