(defun monty-hall (strategy &aux (winner (random 3)) (choice (random 3))) (let ((monty (if (= winner choice) (do ((x (random 3) (random 3))) ((/= x winner) x)) (- 3 (+ winner choice))))) (case strategy (:stay (= winner choice)) (:change (= winner (- 3 (+ choice monty)))))))
Incidentally, I think the code in the original article provides a good example of how code can be so verbose as to detract from understanding. Good code clarifies a problem rather than obfuscating it under the weight of useless detail.
Incidentally, I think the code in the original article provides a good example of how code can be so verbose as to detract from understanding. Good code clarifies a problem rather than obfuscating it under the weight of useless detail.