Skip to content

Instantly share code, notes, and snippets.

@cataska
Last active April 13, 2022 01:39
Show Gist options
  • Save cataska/4c8437287048256d97eed95881f017ca to your computer and use it in GitHub Desktop.
Save cataska/4c8437287048256d97eed95881f017ca to your computer and use it in GitHub Desktop.
(setf *random-state* (make-random-state t))
(defun dice ()
(random 2))
(defun roll (n)
(let ((x 0)
(count 0))
(loop while (< x n) do
(incf count)
(if (= 1 (dice))
(incf x)
(setq x 0)))
count))
(defvar times 10)
(loop for i from 1 to times do
(format t "#~A 第 ~A 次:擲出 ~A 次正面~%" i (roll times) times))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment