Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numpy import zeros, int
- def permutations(n, length):
- numbers = range(n)
- permutations = n**length
- output = zeros((permutations, length), dtype=int)
- for i in range(length):
- t2 = n**i
- p1 = 0
- while (p1 < permutations):
- for al in range(n):
- for p2 in range(t2):
- output[p1, i] = numbers[al]
- p1 += 1
- return output
- line1 = 'a*(b+c*a)*0'
- line2 = 'a*(b+c*-a)*0'
- signs = {'*' : ' and ',
- '+' : ' or ',
- '-' : ' not ',
- '%' : ' | '}
- perm = permutations(2,3)
- fline1 = ''
- fline2 = ''
- for ch in line1:
- if ch in signs:
- ch = signs[ch]
- fline1+=ch
- for ch in line2:
- if ch in signs:
- ch = signs[ch]
- fline2+=ch
- for var_list in perm:
- a,b,c = var_list
- if eval(fline1) == eval(fline2):
- continue
- else:
- print("Формулы не эквивалентны")
- break
- else:
- print("Формулы эквивалентны")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement