/* Meeting problem in Picat. (I'm not sure about the source. The page I got it from does not exist anymore.) """ Let's say that 4 people agree to meet between 3:00 P.M. and 4:00 P.M.. One man can wait for 10 minutes. Another can wait for 15 minutes. Another can wait for 20 Minutes, and another still can wait for 30 minutes. What is the probability that all 4 will meet? """ Note: The meeting must be in the range 3:00pm and 4:00pm. Cf ppl_meeting_problem,pi Cf my Gamble model gamble_meeting_problem2.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. main => go. /* var : prob Probabilities: false: 0.9999900000000000 true: 0.0000100000000000 mean = [false = 0.99999,true = 0.00001] */ go ?=> reset_store, run_model(100_000,$model,[show_probs_trunc,mean]), nl, % show_store_lengths, % fail, nl. go => true. model() => T = 61, % Start times + the wait times A = random_integer(T-10), % a will arrive between 0 and 50 AW = random_integer(10+1), B = random_integer(T-15), BW = random_integer(15+1), C = random_integer(T-20), CW = random_integer(20+1), D = random_integer(T-30), DW = random_integer(30+1), Prob = check(( A+AW == B+BW, B+BW == C+CW, C+CW == D+DW)), add("prob",Prob).