Guest User

Untitled

a guest
Oct 29th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. p(450). p(525). p(600).
  2. p(675). p(750). p(825). p(900).
  3. d(belhino). d(eldang). d(mechania).
  4. d(motomiya). d(suzutake). d(werril). d(zarobit).
  5. r(100). r(150). r(250).
  6. r(350). r(475). r(650). r(1000).
  7. f(10). f(15). f(20).
  8. f(25). f(30). f(40). f(60).
  9.  
  10. myselect([], _).
  11. myselect([A|B],C) :- myselect(A,C,D), myselect(B,D).
  12.  
  13. unique([]).
  14. unique([X|Xs]) :- \+ memberchk(X, Xs), unique(Xs).
  15.  
  16. clue1(Sol) :-
  17. member([825,_,R1,F1],Sol),
  18. member([P2,_,250,F2],Sol),
  19. member([P3,_,R3,20],Sol),
  20. member([P4,_,475,F4],Sol),
  21. member([P5,_,150,F5],Sol),
  22. member([P6,_,350,F6],Sol),
  23. member([P7,_,R7,40],Sol),
  24. unique([P2,P3,P4,P5,P6,P7,825]),
  25. unique([R1,R3,R7,250,475,150,350]),
  26. unique([F1,F2,F4,F5,F6,20,40]).
  27.  
  28. clue2(Sol) :-
  29. member([P1,_,650,_],Sol),
  30. member([P2,mechania,_,_],Sol),
  31. P1 > P2.
  32.  
  33. clue3(Sol) :-
  34. member([P,D,_,60],Sol),
  35. (P == 750 ; D == eldang).
  36.  
  37. clue4(Sol) :-
  38. (member([900,_,350,_],Sol),
  39. member([_,belhino,_,25],Sol))
  40. ;
  41. (member([900,belhino,_,_],Sol),
  42. member([_,_,350,25],Sol)).
  43.  
  44. clue5(Sol) :-
  45. (member([900,_,_,20],Sol),
  46. member([_,zarobit,150,_],Sol))
  47. ;
  48. (member([900,_,150,_],Sol),
  49. member([_,zarobit,_,20],Sol)).
  50.  
  51. clue6(Sol) :-
  52. (member([_,_,100,40],Sol),
  53. member([825,_,_,15],Sol))
  54. ;
  55. (member([825,_,_,40],Sol),
  56. member([_,_,100,15],Sol)).
  57.  
  58. clue7(Sol) :-
  59. member([_,_,R,10],Sol),
  60. R \== 475.
  61.  
  62. clue8(Sol) :-
  63. member([P1,mechania,_,_],Sol),
  64. member([P2,eldang,_,_],Sol),
  65. P1 =:= P2 + 225.
  66.  
  67. clue9(Sol) :-
  68. member([P,werril,_,_],Sol),
  69. (P == 450 ; P == 750).
  70.  
  71. clue10(Sol) :-
  72. member([P1,_,350,_],Sol),
  73. member([P2,werril,_,_],Sol),
  74. P1 < P2.
  75.  
  76. clue11(Sol) :-
  77. member([_,suzutake,R,_],Sol),
  78. R \== 350.
  79.  
  80. clue12(Sol) :-
  81. member([P1,motomiya,_,F1],Sol),
  82. member([P2,D2,_,20],Sol),
  83. member([525,D3,_,F3],Sol),
  84. unique([P1,P2,525]),
  85. unique([D2,D3,motomiya]),
  86. unique([F1,F3,20]).
  87.  
  88. clue13(Sol) :-
  89. member([P1,zorobit,_,_],Sol),
  90. member([P2,_,_,10],Sol),
  91. P1 =:= P2 + 225.
  92.  
  93. solve(Sol) :-
  94.  
  95. freeze(Sol,clue1(Sol)),
  96. freeze(Sol,clue2(Sol)),
  97. freeze(Sol,clue3(Sol)),
  98. freeze(Sol,clue4(Sol)),
  99. freeze(Sol,clue5(Sol)),
  100. freeze(Sol,clue6(Sol)),
  101. freeze(Sol,clue7(Sol)),
  102. freeze(Sol,clue8(Sol)),
  103. freeze(Sol,clue9(Sol)),
  104. freeze(Sol,clue10(Sol)),
  105. freeze(Sol,clue11(Sol)),
  106. freeze(Sol,clue12(Sol)),
  107. freeze(Sol,clue13(Sol)),
  108.  
  109. p(P1),p(P2),p(P3),
  110. p(P4),p(P5),p(P6),p(P7),
  111. unique([P1,P2,P3,P4,P5,P6,P7]),
  112. d(D1),d(D2),d(D3),
  113. d(D4),d(D5),d(D6),d(D7),
  114. unique([D1,D2,D3,D4,D5,D6,D7]),
  115. r(R1),r(R2),r(R3),
  116. r(R4),r(R5),r(R6),r(R7),
  117. unique([R1,R2,R3,R4,R5,R6,R7]),
  118. f(F1),f(F2),f(F3),
  119. f(F4),f(F5),f(F6),f(F7),
  120. unique([F1,F2,F3,F4,F5,F6,F7]),
  121.  
  122. Sol = [[P1,D1,R1,F1],
  123. [P2,D2,R2,F2],
  124. [P3,D3,R3,F3],
  125. [P4,D4,R4,F4],
  126. [P5,D5,R5,F5],
  127. [P6,D6,R6,F6],
  128. [P7,D7,R7,F7]
  129. ].
Advertisement
Add Comment
Please, Sign In to add comment