S'identifier - S'inscrire - Contact

CommunityWiki
Jam session in wikilandia

Emacs and Dice

Source :

Somebody asked on Google+: What are the odds for rolling 2d10 and a d20 and getting higher on the 2d10?(let ((a 0) (b 0) (n 0)) (insert "2d10 vs. 1d20") (newline) (newline) (insert " ") (dotimes (roll-1 10) (dotimes (roll-2 10) (insert (format " %5s" (concat (number-to-string (1+ roll-1)) "+" (number-to-string (1+ roll-2))))))) (newline) (dotimes (roll-3 20) (insert (format " %4d" (1+ roll-3))) (dotimes (roll-1 10) (dotimes (roll-2 10) (insert " " (cond ((> (+ 2 roll-1 roll-2) (1+ roll-3)) (incf a) "A") ((= (+ 2 roll-1 roll-2) (1+ roll-3)) (incf n) "-") (t (incf b) "B"))))) (newline)) (newline) (let ((total (+ a b n))) (insert (format "A: %d / %d = %4.3f\n" a total (/ a 1.0 total))) (insert (format "B: %d / %d = %4.3f\n" b total (/ b 1.0 total))) (insert (format "-: %d / %d = %4.3f\n" n total (/ n 1.0 total)))) (newline) (newline))

2d10 vs. 1d20

1+1 1+2 1+3 1+4 1+5 1+6 1+7 1+8 1+9 1+10 2+1 2+2 2+3 2+4 2+5 2+6 2+7 2+8 2+9 2+10 3+1 3+2 3+3 3+4 3+5 3+6 3+7 3+8 3+9 3+10 4+1 4+2 4+3 4+4 4+5 4+6 4+7 4+8 4+9 4+10 5+1 5+2 5+3 5+4 5+5 5+6 5+7 5+8 5+9 5+10 6+1 6+2 6+3 6+4 6+5 6+6 6+7 6+8 6+9 6+10 7+1 7+2 7+3 7+4 7+5 7+6 7+7 7+8 7+9 7+10 8+1 8+2 8+3 8+4 8+5 8+6 8+7 8+8 8+9 8+10 9+1 9+2 9+3 9+4 9+5 9+6 9+7 9+8 9+9 9+10 10+1 10+2 10+3 10+4 10+5 10+6 10+7 10+8 10+9 10+10 [..]

le 22.08.14 à 09:25 dans Mind - Version imprimable
Article précédent - Commenter - Article suivant -