# Encoding minimum_postage_stamp_problem.gringo

Name minimum_postage_stamp_problem.gringo [Root]    Puzzles (51) Oliver Matheis Oliver Matheis Limit for the number of stamps on an envelope must be smaller than 6 2011-10-28 22:06 2011-10-28 22:15 MinimumPostageStampProblem bound/1limit/1 m/1 No % The minimum postage stamp problem asks for a minimal set of stamp types that % allow to combine all postage values from 1 to a specified bound, when an % envelope can hold only a limited number of stamps. % bound(N). is specified in the instance. % limit(M). is specified in the instance. error("limit > 5"):-limit(L),L > 5. d(1..N):-bound(N), not error("limit > 5"). #count{m(X)}:-d(X). ok(X):-m(X), limit(L),L>=1. ok(X):-m(A),m(B), limit(L),L>=2, d(X),d(A),d(B), A<=B, X:=A+B. ok(X):-m(A),m(B),m(C), limit(L),L>=3, d(X),d(A),d(C),d(B), A<=B,B<=C, X:=A+B+C. ok(X):- m(A),m(B),m(C),m(D), limit(L),L>=4, d(X),d(A),d(D),d(C),d(B), A<=B,B<=C,C<=D, X:=A+B+C+D. ok(X):-m(A),m(B),m(C),m(D),m(E), limit(L),L>=5, d(X),d(A),d(E),d(D),d(C),d(B), A<=B,B<=C,C<=D,D<=E, X:=A+B+C+D+E. :-not ok(X),d(X). #minimize{m(X)}. #hide. #show m/1. #show error/1.