Skip to content

Instantly share code, notes, and snippets.

@apg
Created February 10, 2012 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apg/1789263 to your computer and use it in GitHub Desktop.
Save apg/1789263 to your computer and use it in GitHub Desktop.
(define (game min max)
(let* ((guess (floor (/ (+ min max) 2)))
(hl (begin (format #t "is your number ~a?\n(h)igher/(l)ower/(c)orrect: " guess) (read))))
(cond
((eq? hl 'h) (game guess max))
((eq? hl 'l) (game min guess))
((eq? hl 'c) (format #t "I win!\n"))
(else (game min max)))))
(game 0 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment