17/03/05 09:20:54.74 FnE3e1tn.net
>>134 Emacs Lisp
(require 'cl-lib)
(defun dice (x y)
(let ((b '(0)))
(dotimes (i y)
(setq b (reduce (lambda (a b) (append a b)) (loop for n in (loop for i from 1 to x collect i) collect (loop for m in b collect (+ n m))))))
(pp (loop for n in (remove-duplicates b) collect (list n (count n b) (/ (float (count n b)) (length b)))))))
(dice 6 3)
((3 1 0.004629629629629629)
(4 3 0.013888888888888888)
(5 6 0.027777777777777776)
(6 10 0.046296296296296294)
(7 15 0.06944444444444445)
(8 21 0.09722222222222222)
(9 25 0.11574074074074074)
(10 27 0.125)
(11 27 0.125)
(12 25 0.11574074074074074)
(13 21 0.09722222222222222)
(14 15 0.06944444444444445)
(15 10 0.046296296296296294)
(16 6 0.027777777777777776)
(17 3 0.013888888888888888)
(18 1 0.004629629629629629))