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).
- myall_unique(List) :- all_unique(List, []).
- all_unique([], _).
- all_unique([X|Xs], Seen) :-
- not_in(Seen, X),
- all_unique(Xs, [X|Seen]).
- not_in([], _).
- not_in([X|Xs], Y) :-
- dif(X, Y),
- not_in(Xs, Y).
- select4([],[],[],[],[]).
- select4(Ps,Ds,Rs,Fs,[[P,D,R,F]|Sol0]) :-
- select(P,Ps,Ps0),
- select(D,Ds,Ds0),
- select(R,Rs,Rs0),
- select(F,Fs,Fs0),
- select4(Ps0,Ds0,Rs0,Fs0,Sol0).
- clue1(Sol) :-
- freeze(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),
- when((
- ground(R1),ground(F1),
- ground(P2),ground(F2),
- ground(P3),ground(R3),
- ground(P4),ground(F4),
- ground(P5),ground(F5),
- ground(P6),ground(F6),
- ground(P7),ground(R7)),(
- myall_unique([P2,P3,P4,P5,P6,P7,825]),
- myall_unique([R1,R3,R7,250,475,150,350]),
- myall_unique([F1,F2,F4,F5,F6,20,40])
- ))
- )).
- clue2(Sol) :-
- freeze(Sol,(
- member([P1,_,650,_],Sol),
- member([P2,mechania,_,_],Sol),
- when((ground(P1),ground(P2)),(P1 > P2))
- )).
- clue3(Sol) :-
- freeze(Sol,(
- member([P,D,_,60],Sol),
- when((ground(P),ground(D)),(P == 750 ; D == eldang))
- )).
- clue4(Sol) :-
- freeze(Sol,(
- (member([900,_,350,_],Sol),
- member([_,belhino,_,25],Sol))
- ;
- (member([900,belhino,_,_],Sol),
- member([_,_,350,25],Sol))
- )).
- clue5(Sol) :-
- freeze(Sol,(
- (member([900,_,_,20],Sol),
- member([_,zarobit,150,_],Sol))
- ;
- (member([900,_,150,_],Sol),
- member([_,zarobit,_,20],Sol))
- )).
- clue6(Sol) :-
- freeze(Sol,(
- (member([_,_,100,40],Sol),
- member([825,_,_,15],Sol))
- ;
- (member([825,_,_,40],Sol),
- member([_,_,100,15],Sol))
- )).
- solve(Sol) :-
- findall(P,p(P),Ps),
- findall(D,d(D),Ds),
- findall(R,r(R),Rs),
- findall(F,f(F),Fs),
- clue1(Sol),
- clue2(Sol),
- clue3(Sol),
- clue4(Sol),
- clue5(Sol),
- clue6(Sol),
- select4(Ps,Ds,Rs,Fs,Sol).
Advertisement
Add Comment
Please, Sign In to add comment