# VI Prv kolokvium Constraint problem

Jun 16th, 2021
1,174
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from constraint import *
2.
3. def gethelp(x, y):
4.     if x == "Mon_10" or x == "Wed_10" or "Fri_10" and y == "Tue_10" or "Thu_10":
5.         return True
6.     if x == "Mon_11" or x == "Wed_11" or "Fri_11" and y == "Tue_11" or "Thu_11":
7.         return True
8.
9. def diff(x,y):
10.     x = x.split("_")
11.     y = y.split("_") # split day and hour
12.     if x[0] == y[0]: # if day is the same
13.         if abs(int(x[1]) - int(y[1])) >=2 : # ako razlikata megu terminite e 2 ili pojse saata
14.             return True # togi moze
15.     if x[0] != y[0]: # ako ne e istiot dennnnn sta kaze
16.         return True # mozeeeee
17.
18.
19.
20. if __name__ == '__main__':
21.     problem = Problem(BacktrackingSolver())
22.     casovi_AI = input()
23.     casovi_ML = input()
24.     casovi_R = input()
25.     casovi_BI = input()
26.
27.     AI_predavanja_domain = ["Mon_11", "Mon_12", "Wed_11", "Wed_12", "Fri_11", "Fri_12"]
28.     ML_predavanja_domain = ["Mon_12", "Mon_13", "Mon_15", "Wed_12", "Wed_13", "Wed_15", "Fri_11", "Fri_12", "Fri_15"]
29.     R_predavanja_domain = ["Mon_10", "Mon_11", "Mon_12", "Mon_13","Mon_14", "Mon_15", "Wed_10", "Wed_11", "Wed_12", "Wed_13","Wed_14", "Wed_15", "Fri_10", "Fri_11", "Fri_12", "Fri_13","Fri_14", "Fri_15"]
30.     BI_predavanja_domain = ["Mon_10", "Mon_11", "Wed_10", "Wed_11", "Fri_10", "Fri_11"]
31.
32.     AI_vezbi_domain = ["Tue_10", "Tue_11", "Tue_12", "Tue_13", "Thu_10", "Thu_11", "Thu_12", "Thu_13"]
33.     ML_vezbi_domain = ["Tue_11", "Tue_13", "Tue_14", "Thu_11", "Thu_13", "Thu_14"]
34.     BI_vezbi_domain = ["Tue_10", "Tue_11", "Thu_10", "Thu_11"]
35.
36.     # ---Tuka dodadete gi promenlivite--------------------
37.     variables = []
38.
39.     for i in range(0, int(casovi_AI)):
41.         variables.append("AI_cas_" + str(i+1))
42.     for i in range(0, int(casovi_R)):
44.         variables.append("R_cas_" + str(i+1))
45.     for i in range(0, int(casovi_ML)):
47.         variables.append("ML_cas_" + str(i+1))
48.     for i in range(0, int(casovi_BI)):
50.         variables.append("BI_cas_" + str(i+1))
51.     # voa ako e okej se farbam zelena
52.
54.     variables.append("AI_vezbi")
56.     variables.append("BI_vezbi")
58.     variables.append("ML_vezbi")
59.
60.
61.     # ---Tuka dodadete gi ogranichuvanjata----------------
62.