Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #a = '-((-(x & 56 <> 0) v (x & 18 <> 0)) v (x & A <> 0)) v ((x & 18 = 0) ^ (x & A = 0) ^ (x & 43 <> 0)) '
- a = '((x1 ∨ x2) ∧ (-(x1 ∧ x2) v y1)) and ((x2 ∨ x3) ∧ (-(x2 ∧ x3) v y2)) and ((x3 ∨ x4) ∧ (-(x3 ∧ x4) v y3)) and ((x4 ∨ x5) ∧ (-(x4 ∧ x5) v y4)) and ((x5 ∨ x6) ∧ (x5 ∨ y5)) and (x6 ∨ y6)'
- a = '''
- ((x1 ∨ x2) ∧ (-(x1 ∧ x2) or x3) ∧ (x1 ∨ y1)) and \
- ((x2 ∨ x3) ∧ (-(x2 ∧ x3) or x4) ∧ (x2 ∨ y2)) and \
- ((x3 ∨ x4) ∧ (-(x3 ∧ x4) or x5) ∧ (x3 ∨ y3)) and \
- ((x4 ∨ x5) ∧ (-(x4 ∧ x5) or x6) ∧ (x4 ∨ y4)) and \
- ((x5 ∨ x6) ∧ (-(x5 ∧ x6) or x7) ∧ (x5 ∨ y5)) and \
- ((x6 ∨ x7) ∧ (-(x6 ∧ x7) or x8) ∧ (x6 ∨ y6)) and \
- ((x7 ∨ x8) ∧ (x7 ∨ y7)) and \
- (x8 ∨ y8) = 1
- '''
- nx = 8
- ny = 8
- a = a.replace('v',' or ')
- a = a.replace('∨',' or ')
- a = a.replace('^',' and ')
- a = a.replace('∧',' and ')
- a = a.replace('-',' not ')
- a = a.replace('¬',' not ')
- #a = a.replace('ДЕЛ',' test_del')
- a = a.replace('А','A')
- a = a.replace('X','x')
- a = a.replace('≠','!=')
- a = a.replace('<>','!=')
- a = a.replace(' = ',' == ')
- a = ' '.join([x for x in a.split(' ') if x])
- print(a)
- print()
- def tobin(a,n):
- res = ''
- while a:
- res = str(a % 2) + res
- a = a // 2
- n = n - len(res)
- if n > 0:
- res = '0'*n + res
- return list(map(int,res))
- kx = 0
- k = 0
- for x in range(2**nx):
- xx = tobin(x,nx)
- test_a = a
- for ii in range(1,nx+1):
- test_a = test_a.replace('x'+str(ii),str(xx[ii-1]))
- for ii in range(1,ny+1):
- test_a = test_a.replace('y'+str(ii),'1')
- if eval(test_a):
- print(''.join(map(str,xx)), end= ' >> ')
- kx += 1
- ky = 0
- for y in range(2**ny):
- yy = tobin(y,ny)
- test_a = a
- for ii in range(1,nx+1):
- test_a = test_a.replace('x'+str(ii),str(xx[ii-1]))
- for ii in range(1,ny+1):
- test_a = test_a.replace('y'+str(ii),str(yy[ii-1]))
- if eval(test_a):
- ky += 1
- k += 1
- #print(*yy)
- print(ky)
- print(kx,k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement