/* McNuggets Problem (Rosetta Code) in Picat. http://rosettacode.org/wiki/McNuggets_Problem#MiniZinc """ From Wikipedia: ''' The McNuggets version of the coin problem was introduced by Henri Picciotto, who included it in his algebra textbook co-authored with Anita Wah. Picciotto thought of the application in the 1980s while dining with his son at McDonald's, working the problem out on a napkin. A McNugget number is the total number of McDonald's Chicken McNuggets in any number of boxes. In the United Kingdom, the original boxes (prior to the introduction of the Happy Meal-sized nugget boxes) were of 6, 9, and 20 nuggets. ''' Task Calculate (from 0 up to a limit of 100) the largest non-McNuggets number (a number n which cannot be expressed with 6x + 9y + 20z = n where x, y and z are natural numbers). """ Also see: http://hakank.org/picat/frobenius_number.pi This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => N :: 0..100, foreach(X in 0..16, Y in 0..11, Z in 0..5) 6*X + 9*Y + 20*Z #!= N end, solve($[max(N)],N), println(n=N), nl. go2 => T = [N : N in 1..100, member(X,0..16), member(Y,0..11), member(Z,0..5), 6*X + 9*Y + 20*Z != N], println(t=T), println(max=Max), nl.