Advertisement
Andrei90

C14-H

Jan 18th, 2022
665
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. grupa(1,romania).  
  2. grupa(1,cehia).  
  3. grupa(1,norvegia).
  4. grupa(1,germania).
  5.  
  6. grupa(2,spania).
  7. grupa(2,ungaria).  
  8. grupa(2,croatia).
  9.  
  10.  
  11. scor(romania,norvegia,30, 20).
  12. scor(romania,cehia,25, 20).
  13. scor(germania, romania, 22, 23).
  14. scor(cehia,norvegia,20, 22).
  15.  
  16. castigate(G,X,EI,SX,SE):-
  17. grupa(G,X),
  18. ((scor(X,EI,SX,SE) , SX>SE) ;
  19. (scor(EI,X,SE,SX) , SX> SE)),
  20. write(X),write('-'),
  21. write(EI),write(': '),
  22. write(SX),write('-'),
  23. write(SE),
  24. nl.
  25.  
  26. /*L=[e1,e2,e3,e4]
  27.     e1: [e2,e3,e4] e1-e2, %e2-e1
  28.         [e3,e4]    e1-e3,
  29.         [e4]       e1-e4
  30.         []         STOP
  31.    
  32.     e2: [e3,e4]    e2-e3
  33.         [e4]       e2-e4
  34.         []         STOP
  35.        
  36.     e3: [e4]       e3-e4
  37.         []         STOP
  38.        
  39.     e4: []         STOP
  40. */
  41.  
  42. perm_echi(E,[],LM):-
  43. LM = [].
  44.  
  45. perm_echi(E,LE,LM):-
  46. LE=[H|LE1],
  47. MC=[E,H], %MC2=[H,E]
  48. perm_echi(E,LE1,LM1),
  49. append([MC],LM1,LM). %LM=[MC|LM1]
  50. %append([MC, MC2], LM1, LM)
  51. %LM=[MC,MC2|LM1]
  52.  
  53. meciuri1G([],LM):-
  54. LM=[].
  55.  
  56. meciuri1G(LE,LM):-
  57. LE=[H|LE1],
  58. perm_echi(H,LE1,LM1),
  59. meciuri1G(LE1,LMR),
  60. append(LMR,LM1,LM).
  61.  
  62. afisare1G(G,LM):- %G ct in intrebare
  63. findall(E,grupa(G,E),LE),
  64. meciuri1G(LE,LM),
  65. write(LM),
  66. nl.
  67.  
  68. afisareTG(LM):-
  69. findall(G,grupa(G,_),LG),
  70. sort(LG,LGS),
  71. findall(Z,(member(GH,LGS),afisare1G(GH,LMG),member(Z,LMG)),LM).
  72.  
  73. perm_echiV2(E,LE,LM):- %E e o ct
  74. findall(Var,(member(Y,LE),Var=[E,Y]),LM).
  75.  
  76. /*L=[e2,e3,e4], E=e1
  77.  
  78. Y=e2, Var=[e1,e2]
  79. Y=e3, Var=[e1,e3]
  80. Y=e4, Var=[e1,e4]
  81. */
  82. %findall(Var,(member(Y,LE),L=[[E,Y],[Y,E]],member(Var,L)),LM).
  83. %findall(Var,(member(Y,LE),Var=[E,Y]),LM1),
  84. %findall(Var,(member(Y,LE),Var=[Y,E]),LM2),
  85. %append(LM1,LM2,LM).
  86.  
  87. meciuri1G_V2(LE,LM):-
  88. findall(M,(member(X,LE),exclude(X,LE,LX),perm_echiV2(X,LX,LM1),
  89. member(M,LM1)),LM).
  90.  
  91. exclude(X,L,LX):-
  92. findall(Y,(member(Y,L),Y\=X),LX).
  93.  
  94. /* L=[e1,e2,e3,e4],
  95. X=e1 LX=[e2,e3,e4] LM1=[e1-e2,e1-e3,e1-e4]       %[[e1,e2],[e1,e3],[e1,e4]]
  96. X=e2 LX=[e1,e3,e4] LM1=[[e2,e1],[e2,e3],[e2,e4]] %[[e1,e2],[e2,e3],[e2,e4]]
  97. X=e3
  98. X=e4*/
  99.  
  100. meciuri1G_V3(LE,LM):-
  101. findall(M,(member(X,LE),exclude(X,LE,LX),perm_echiV2(X,LX,LM1),
  102. member(M,LM1)),LM).
  103.  
  104. perm_echiV3(E,LE,LM):- %E e o ct
  105. findall(Var,(member(Y,LE),Var1=[E,Y],sort(Var1,Var)),LM1),
  106. sort(LM1,LM).
  107.  
  108. meci_grupa(G,L):-
  109. findall([E1,E2],(grupa(G,E1),grupa(G,E2),E1\=E2,E1@>=E2),L).
  110.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement