Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. from numpy import zeros, int
  2.  
  3. def permutations(n, length):
  4.     numbers = range(n)
  5.     permutations = n**length
  6.     output = zeros((permutations, length), dtype=int)
  7.  
  8.     for i in range(length):
  9.         t2 = n**i
  10.         p1 = 0
  11.         while (p1 < permutations):
  12.             for al in range(n):
  13.                 for p2 in range(t2):
  14.                     output[p1, i] = numbers[al]
  15.                     p1 += 1
  16.     return output
  17.  
  18.  
  19.  
  20. line1 = 'a*(b+c*a)*0'
  21. line2 = 'a*(b+c*-a)*0'
  22.  
  23. signs = {'*' : ' and ',
  24.          '+' : ' or ',
  25.          '-' : ' not ',
  26.          '%' : ' | '}
  27.  
  28.  
  29. perm = permutations(2,3)
  30.  
  31. fline1 = ''
  32. fline2 = ''
  33. for ch in line1:
  34.     if ch in signs:
  35.         ch = signs[ch]
  36.     fline1+=ch
  37. for ch in line2:
  38.     if ch in signs:
  39.         ch = signs[ch]
  40.     fline2+=ch
  41. for var_list in perm:
  42.         a,b,c = var_list
  43.         if eval(fline1) == eval(fline2):
  44.                 continue
  45.         else:
  46.                 print("Формулы не эквивалентны")
  47.                 break
  48. else:
  49.         print("Формулы эквивалентны")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement