Update truth_table.py
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
evalStr = input()
|
evalStr = input()
|
||||||
newStr = evalStr.replace("!", " not ").replace("*", " and ").replace("+", " or ")
|
newStr = evalStr.replace("!", " ~ ").replace("*", " & ").replace("+", " | ")
|
||||||
variables = []
|
variables = []
|
||||||
for x in evalStr:
|
for x in evalStr:
|
||||||
if x.isalpha() and not(x in variables):
|
if x.isalpha() and not(x in variables):
|
||||||
@@ -8,6 +8,7 @@ n = len(variables)
|
|||||||
for x in variables:
|
for x in variables:
|
||||||
print("|", x, end=" ")
|
print("|", x, end=" ")
|
||||||
print("|", evalStr, "|")
|
print("|", evalStr, "|")
|
||||||
|
print("-" * ((len(evalStr)+4) + n*4))
|
||||||
for x in range(0, 2**n):
|
for x in range(0, 2**n):
|
||||||
temp = []
|
temp = []
|
||||||
for i in range(n):
|
for i in range(n):
|
||||||
|
|||||||
Reference in New Issue
Block a user