Task

Write a game (computer program) that follows the following rules:

 The computer chooses a number between given set limits.
 The player is asked for repeated guesses until the the target number is guessed correctly
 At each guess, the computer responds with whether the guess is:
 higher than the target,
 equal to the target, 
 less than the target,   or
 the input was inappropriate. 


Related task

   Guess the number/With Feedback (Player)


(defn guess-run []
  (let [start 1
	end 100
	target (+ start (rand-int (inc (- end start))))]
    (printf "Guess a number between %d and %d" start end)
    (loop [i 1]
      (printf "Your guess %d:\n" i)
      (let [ans (read)]
	(if (cond
	     (not (number? ans)) (println "Invalid format")
	     (or (< ans start) (> ans end)) (println "Out of range")
	     (< ans target)    (println "too low")
	     (> ans target)    (println "too high")
	     :else             true)
	  (println "Correct")
	  (recur (inc i)))))))