summaryrefslogtreecommitdiffstats
path: root/two
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-07-03 15:47:02 -0400
committerrsiddharth <s@ricketyspace.net>2020-07-03 15:47:02 -0400
commit0f072be231d0bd875d1c87ff127834e60979263a (patch)
tree19010b72474c14a04891abbe3da0fb5d58067db9 /two
parent4f731f11be9d5bbfcd921671852e514e577a0c00 (diff)
net/ricketyspace/ror -> ./
Diffstat (limited to 'two')
-rw-r--r--two/guess.rkt21
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))