mralex18

2egeinf

Jun 10th, 2021
508
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from itertools import combinations, permutations
  2.  
  3. def imp(a, b):
  4.     return not a or b
  5. def srav(a, b):
  6.     for i in range(len(a)):
  7.         for j in range(len(a[i])):
  8.             if b[i][j] == 1 and a[i][j] == 0 or a[i][j] == 1 and b[i][j] == 0:
  9.                 return False
  10.     return True
  11. table = []
  12. s = [False, True]
  13. '''
  14. '''
  15. def f(a, b, c, d):
  16.     return not imp(b, a) and imp(c, d) or a and b and c and not d
  17. table_quest = [
  18.     [ -1,  0,  0,  0,  1],
  19.     [ -1, -1, -1,  0,  1],
  20.     [ -1, -1,  0,  0,  1],
  21.     [ -1,  0, -1, -1,  1]
  22. ]
  23. sa = 'abcd'
  24. for a in s:
  25.     for b in s:
  26.         for c in s:
  27.             for d in s:
  28.                 table.append([int(a), int(b), int(c), int(d), int(f(a, b, c, d))])
  29. '''
  30. '''
  31. for pt in combinations(table, len(table_quest)):
  32.     for p in permutations(pt):
  33.         #print(p)
  34.         st = []
  35.         for i in range(len(sa)):
  36.             q = []
  37.             for j in range(len(table_quest)):
  38.                 q.append(p[j][i])
  39.             q.append(sa[i])
  40.             st.append(q)
  41.         for perm in permutations(st):
  42.             table_ans = []
  43.             for i in range(len(table_quest)):
  44.                 string = []
  45.                 for j in range(len(sa)):
  46.                     string.append(perm[j][i])
  47.                 string.append(p[i][-1])
  48.                 table_ans.append(string)
  49.             #print(table_ans)
  50.             if srav(table_ans, table_quest):
  51.                 for i in range(len(sa)):
  52.                     print(perm[i][-1], end = '')
  53.                 print('')
  54.  
RAW Paste Data