Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p(450). p(525). p(600).
- p(675). p(750). p(825). p(900).
- d(belhino). d(eldang). d(mechania).
- d(motomiya). d(suzutake). d(werril). d(zarobit).
- r(100). r(150). r(250).
- r(350). r(475). r(650). r(1000).
- f(10). f(15). f(20).
- f(25). f(30). f(40). f(60).
- myselect([], _).
- myselect([A|B],C) :- myselect(A,C,D), myselect(B,D).
- unique([]).
- unique([X|Xs]) :- \+ memberchk(X, Xs), unique(Xs).
- clue1(Sol) :-
- member([825,_,R1,F1],Sol),
- member([P2,_,250,F2],Sol),
- member([P3,_,R3,20],Sol),
- member([P4,_,475,F4],Sol),
- member([P5,_,150,F5],Sol),
- member([P6,_,350,F6],Sol),
- member([P7,_,R7,40],Sol),
- unique([P2,P3,P4,P5,P6,P7,825]),
- unique([R1,R3,R7,250,475,150,350]),
- unique([F1,F2,F4,F5,F6,20,40]).
- clue2(Sol) :-
- member([P1,_,650,_],Sol),
- member([P2,mechania,_,_],Sol),
- P1 > P2.
- clue3(Sol) :-
- member([P,D,_,60],Sol),
- (P == 750 ; D == eldang).
- clue4(Sol) :-
- (member([900,_,350,_],Sol),
- member([_,belhino,_,25],Sol))
- ;
- (member([900,belhino,_,_],Sol),
- member([_,_,350,25],Sol)).
- clue5(Sol) :-
- (member([900,_,_,20],Sol),
- member([_,zarobit,150,_],Sol))
- ;
- (member([900,_,150,_],Sol),
- member([_,zarobit,_,20],Sol)).
- clue6(Sol) :-
- (member([_,_,100,40],Sol),
- member([825,_,_,15],Sol))
- ;
- (member([825,_,_,40],Sol),
- member([_,_,100,15],Sol)).
- clue7(Sol) :-
- member([_,_,R,10],Sol),
- R \== 475.
- clue8(Sol) :-
- member([P1,mechania,_,_],Sol),
- member([P2,eldang,_,_],Sol),
- P1 =:= P2 + 225.
- clue9(Sol) :-
- member([P,werril,_,_],Sol),
- (P == 450 ; P == 750).
- clue10(Sol) :-
- member([P1,_,350,_],Sol),
- member([P2,werril,_,_],Sol),
- P1 < P2.
- clue11(Sol) :-
- member([_,suzutake,R,_],Sol),
- R \== 350.
- clue12(Sol) :-
- member([P1,motomiya,_,F1],Sol),
- member([P2,D2,_,20],Sol),
- member([525,D3,_,F3],Sol),
- unique([P1,P2,525]),
- unique([D2,D3,motomiya]),
- unique([F1,F3,20]).
- clue13(Sol) :-
- member([P1,zorobit,_,_],Sol),
- member([P2,_,_,10],Sol),
- P1 =:= P2 + 225.
- solve(Sol) :-
- p(P1),p(P2),p(P3),
- p(P4),p(P5),p(P6),p(P7),
- unique([P1,P2,P3,P4,P5,P6,P7]),
- d(D1),d(D2),d(D3),
- d(D4),d(D5),d(D6),d(D7),
- unique([D1,D2,D3,D4,D5,D6,D7]),
- r(R1),r(R2),r(R3),
- r(R4),r(R5),r(R6),r(R7),
- unique([R1,R2,R3,R4,R5,R6,R7]),
- f(F1),f(F2),f(F3),
- f(F4),f(F5),f(F6),f(F7),
- unique([F1,F2,F3,F4,F5,F6,F7]),
- freeze(Sol,clue1(Sol)),
- freeze(Sol,clue2(Sol)),
- freeze(Sol,clue3(Sol)),
- freeze(Sol,clue4(Sol)),
- freeze(Sol,clue5(Sol)),
- freeze(Sol,clue6(Sol)),
- freeze(Sol,clue7(Sol)),
- freeze(Sol,clue8(Sol)),
- freeze(Sol,clue9(Sol)),
- freeze(Sol,clue10(Sol)),
- freeze(Sol,clue11(Sol)),
- freeze(Sol,clue12(Sol)),
- freeze(Sol,clue13(Sol)),
- Sol = [[P1,D1,R1,F1],
- [P2,D2,R2,F2],
- [P3,D3,R3,F3],
- [P4,D4,R4,F4],
- [P5,D5,R5,F5],
- [P6,D6,R6,F6],
- [P7,D7,R7,F7]
- ].
Advertisement
Add Comment
Please, Sign In to add comment