summaryrefslogtreecommitdiffstats
path: root/net/ricketyspace
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-03-10 03:29:02 +0000
committerrsiddharth <s@ricketyspace.net>2018-03-10 03:29:02 +0000
commit74151dfc48e6be6dba11a0776af24c39eb9f592d (patch)
treeb306a3cd83e958f25869d15186a303d0dfd31e3a /net/ricketyspace
parent3817062a59ac8fd467ad99a36d7f9210f60387c4 (diff)
Add net/ricketyspace/ror/two/guess.rkt.
Diffstat (limited to 'net/ricketyspace')
-rw-r--r--net/ricketyspace/ror/two/guess.rkt21
1 files changed, 21 insertions, 0 deletions
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))