24 lines
		
	
	
		
			611 B
		
	
	
	
		
			Common Lisp
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			611 B
		
	
	
	
		
			Common Lisp
		
	
	
	
	
	
(defparameter *small* 1)
 | 
						|
(defparameter *big* 100)
 | 
						|
 | 
						|
(defun guess-my-number ()
 | 
						|
	;; ash is the artithmetic shift function
 | 
						|
	;; Halvs the sum of the limits and shortens the result
 | 
						|
	;; ash, here, shifts the binary bits left or right (well, right in this case)
 | 
						|
	;; Which leads to the right most binary falling off
 | 
						|
	;; This is a binary search
 | 
						|
	(ash (+ *small* *big*) -1))
 | 
						|
 | 
						|
(defun smaller ()
 | 
						|
	(setf *big* (1- (guess-my-number)))
 | 
						|
	(guess-my-number))
 | 
						|
 | 
						|
(defun bigger ()
 | 
						|
	(setf *small* (1+ (guess-my-number)))
 | 
						|
	(guess-my-number))
 | 
						|
 | 
						|
(defun start-over ()
 | 
						|
	(defparameter *small* 1)
 | 
						|
	(defparameter *big* 100)
 | 
						|
	(guess-my-number))
 |