3 ms·
The following lisp simulation gets numbers on about the same order of magnitude: (defun flip () (if (< (random 100) 49) nil t)) (defun game (n d)
by aidenn0 17y ago
The following lisp simulation gets numbers on about the same order of magnitude:
(defun flip () (if (< (random 100) 49) nil t))
(defun game (n d)
(declare (optimize speed))
(if (>= d 10) n
(if (flip)
(game (incf n) (incf d))
(game (incf n) (decf d)))))
(print (nth 1000 (sort (loop for i from 1 to 100000
collect (game 0 0)) #'> )))