- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
Latest commit
29 lines (22 loc) · 624 Bytes
/
Copy pathtest.py
File metadata and controls
29 lines (22 loc) · 624 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
fromcnf2satimportsatisfiable
defstringifyVar(var):
strVar="X"+str(abs(var))
prepend="-"ifvar<0else""
returnprepend+strVar
deftest(expression, expected):
res=satisfiable(expression)
print"Clause:",
foriinrange(len(expression)):
clause=expression[i]
print"("+stringifyVar(clause[0])+" or "+stringifyVar(clause[1])+")",
ifi<len(expression)-1:
print"and",
else:
print""
print"Expected: "+str(expected) +"\nActual: "+str(res) +"\n"
defmain():
expression= [(-1, -2), (1, 2)]
test(expression,True)
expression= [(-1,-1), (1,1)]
test(expression, False)
#main()