Guest User

Untitled

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