Advertisement
Sylv3rWolf

test

Dec 8th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. piatki(X1,X2,Y2,Y3):-
  2. L=[1,2,3,4,5,6,7,8,9],
  3. select(X1,L,_),
  4. select(X2,L,_),
  5. select(Y2,L,_),
  6. select(Y3,L,_),
  7. P11 is (1*X1)//10,
  8. P12 is ((1*X2)+P11) // 10,
  9. S12 is ((1*X2)+P11) mod 10,
  10. S13 is ((1*5)+P12),
  11.  
  12. P21 is (Y2*X1)//10,
  13. P22 is ((Y2*X2)+P21)//10,
  14. P23 is ((Y2*5)+P22)//10,
  15.  
  16. S21 is (Y2*X1) mod 10,
  17. S22 is ((Y2*X2)+P21) mod 10,
  18. S23 is ((Y2*5)+P22) mod 10,
  19. S24 is P23,
  20. S24 \= 0,
  21.  
  22. P31 is (Y3*X1)//10,
  23. P32 is ((Y3*X2)+P31)//10,
  24. P33 is ((Y3*5)+P32)//10,
  25.  
  26. 5 =:= (Y3*X1) mod 10,
  27. S32 is ((Y3*X2)+P31) mod 10,
  28. 5 =:= ((Y3*5)+P32) mod 10,
  29. S34 is P33,
  30. S34 \= 0,
  31.  
  32. 4 =:= (S21 + S12) mod 10,
  33. PW2 is (S21+S12)//10,
  34. PW3 is ((S13 + S22 + 5) + PW2)//10,
  35. 5 =:= (S23 + S32 + PW3) mod 10.
  36.  
  37.  
  38.  
  39. pingpong(P,K,B,E):-
  40. L=[1,2,3,4,5],
  41. select(P,L,L1),
  42. select(K,L1,L2),
  43. select(B,L2,L3),
  44. select(E,L3,_),
  45. E > K,
  46. K > B,
  47. P > K,
  48. P > B,
  49. B + E > P + K.
  50.  
  51. wynik2(A1,A0,B2,B1,B0):-
  52. N = [1,2,3,4,5,6,7,8,9],
  53. L = [1,2,3,4,5,6,7,8,9,0],
  54. select(A1, L,_),
  55. select(A0, L,_),
  56. select(B2, L,_),
  57. select(B1, L,_),
  58. select(B0, L,_),
  59.  
  60. X0 is A0*B0,
  61. X1 is A0*B1 + X0 // 10,
  62. X2 is A0*B2 + X1 // 10,
  63. X3 is X2 // 10,
  64. select(X3, N,_),
  65.  
  66. Y0 is A1*B0,
  67. Y1 is A1*B1 + X0 // 10,
  68. Y2 is A1*B2 + X1 // 10,
  69. Y3 is X2 // 10,
  70. select(Y3, N,_),
  71.  
  72. Z0 is 6*B0,
  73. Z1 is 6*B1 + Z0 // 10,
  74. Z2 is 6*B2 + Z1 // 10,
  75. Z3 is Z2 // 10,
  76. select(Z3, N,_),
  77.  
  78. W0 is X0 mod 10,
  79. W1 is (X1 mod 10) +(Y0 mod 10) + W0 // 10,
  80. W2 is (X2 mod 10) +(Y1 mod 10) + (Z0 mod 10) + W1 // 10,
  81. W3 is (X3 mod 10) +(Y2 mod 10) + (Z1 mod 10) + W2 // 10,
  82. W4 is Z2 + W3//10,
  83. W5 is Z3 + W4//10,
  84. select(W5, N,_),
  85.  
  86. 4 =:= W1 mod 10,
  87. 5 =:= W3 mod 10,
  88. 5 =:= W4 mod 10,
  89.  
  90. true.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement