PasteRack.org
Paste # 9406
2017-08-09 21:49:56

Fork as a new paste.

Paste viewed 39 times.


Embed:

smaller bigger

#lang racket

(define lower 1)
(define upper 100)

(define (guess)
  (quotient (+ lower upper) 2))

(define (smaller)
  (set! upper (max lower (sub1 (guess))))
  (guess))

(define (bigger)
  (set! lower (min upper (add1 (guess))))
  (guess))