re: Daily Coding Puzzles - Nov 4th - Nov 9th VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Monday Number Drills: Blue and red marbles (8 KYU): You've decided to write a function, guess_blue() to help automatically calculate whether you...
 

Common Lisp

(defun guess-blue (blue-in red-in blue-out red-out)
  (let ((blue (- blue-in blue-out))
        (red (- red-in red-out)))
    (/ blue (+ red blue)))

(guess-blue 5 5 2 3)
;; => 3/5

the fun of a language with rationals:

(guess-blue 1 2 0 0)
;; => 1/3
code of conduct - report abuse