/* Dice puzzle in Picat. From Berlin Bayesians: (https://app.slack.com/client/TFPMSKW3F/CFQHMRD6K) """ What's likelier: Rolling at least one six in four throws of a single die, or rolling at least one double 6 in 24 throws of a pair of dice? """ This is de Méré's classical dice puzzle (which induced the study of probability theory). See - https://mathworld.wolfram.com/deMeresProblem.html Cf my Gamble model gamble_dice_puzzle.rkt This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import ppl_distributions, ppl_utils. import util. % import ordset. main => go. /* var : Rolling at least one six in four throws of a single die Probabilities: true: 0.5162000000000000 false: 0.4838000000000000 mean = 0.5162 var : Rolling at least one double six in 24 throws of a pair of dice Probabilities: false: 0.5039000000000000 true: 0.4961000000000000 mean = 0.4961 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => % Case 1: Rolling at least one six in four throws of a single dice SingleDie = dice_n(6,4), P1 = check( count_occurrences(6,SingleDie) >= 1), % Case 2: Rolling at least one double six in 24 throws of a pair of dice TwoDice = [dice_n(6,2) : _ in 1..24], P2 = check( count_occurrences([6,6],TwoDice) >= 1), add("Rolling at least one six in four throws of a single die",P1), add("Rolling at least one double six in 24 throws of a pair of dice",P2).