15 lines
407 B
Common Lisp
15 lines
407 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))))
|
|
(message "Strategy keep: %.3f%%" (/ cnt 100.0)))
|
|
|
|
(let ((cnt 0))
|
|
(dotimes (i 10000)
|
|
(and (montyhall nil) (setq cnt (1+ cnt))))
|
|
(message "Strategy switch: %.3f%%" (/ cnt 100.0)))
|