/* The Arithemtical Cabby in Picat. Puzzle #223 from Dudeney "536 Puzzles and curious problems": """ The driver of the taxi was wanting in civility, so Mr. Wilkins asked him for his number. "You want my number, do you?" said the driver. "Well, work it out for yourself. If you divide my number by 2, 3, 4, 5, or 6 you will find there is always 1 over; but if you divide it by 11 there is no remainder. What’s more, there is no other driver with a lower number who can say the same." What was the fellow's number? """ Solution: The taxi number is 121. The next number with the same property is 781. Here are all numbers less than 9999 with this propery: 121 781 1441 2101 2761 3421 4081 4741 5401 6061 6721 7381 8041 8701 9361 This model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. % Find minimal number go ?=> X :: 0..9999, X mod 11 #= 0, foreach(I in 2..6) X mod I #= 1 end, solve($[min(X),ff,split],X), println(X), nl. go => true. % Find more solutions go2 ?=> X :: 0..9999, X mod 11 #= 0, foreach(I in 2..6) X mod I #= 1 end, solve($[ff,split],X), println(X), fail, nl. go2 => true. /* Porting the Mace4 model from Adrian Groza "Modelling Puzzles in First Order Logic" Same solutions as above: 121 781 1441 2101 2761 3421 4081 4741 5401 6061 6721 7381 8041 8701 9361 */ go3 ?=> Number :: 1..10000, [R2,R3,R4,R5,R6,R11] :: 1..10000, Number #= 2 * R2 + 1, Number #= 3 * R3 + 1, Number #= 4 * R4 + 1, Number #= 5 * R5 + 1, Number #= 6 * R6 + 1, Number #= 11 * R11, Vars = [Number,R2,R3,R4,R5,R6,R11], solve(Vars), println(Number), fail, nl. go3 => true.