RosettaCodeData/Task/Monty-Hall-problem/Emacs-Lisp/monty-hall-problem.l
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

17 lines
429 B
Common Lisp

(defun montyhall (keep)
(let
((prize (random 3))
(choice (random 3)))
(if keep (= prize choice)
(/= prize choice))))
(let ((cnt 0))
(dotimes (i 10000)
(and (montyhall t) (setq cnt (1+ cnt))))
(princ (format "Strategy keep: %.3f %%" (/ cnt 100.0))))
(let ((cnt 0))
(dotimes (i 10000)
(and (montyhall nil) (setq cnt (1+ cnt))))
(princ (format "Strategy switch: %.3f %%" (/ cnt 100.0))))