Advertisement
boris-vlasenko

ege18 проверка битовые операции

Oct 15th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. a = '-(X & 56 ≠ 0) v (-(X & 48 = 0) v (X & A ≠ 0)) '
  2.  
  3.  
  4. a = a.replace('v',' or ')
  5. a = a.replace('∨',' or ')
  6. a = a.replace('^',' and ')
  7. a = a.replace('∧',' and ')
  8. a = a.replace('-',' not ')
  9. a = a.replace('¬',' not ')
  10. #a = a.replace('ДЕЛ',' test_del')
  11. a = a.replace('А','A')
  12. a = a.replace('X','x')
  13. a = a.replace('≠','!=')
  14. a = a.replace('<>','!=')
  15. a = a.replace(' = ',' == ')
  16.  
  17. a = ' '.join([x for x in a.split(' ') if x])
  18. print(a)
  19.  
  20. for A in range(1,100):
  21.     res = True
  22.     for x in range(0,500):
  23.         f = eval(a)
  24.         if not f:
  25.             #print(A,x,f)
  26.             res = False
  27.             break
  28.     if res:
  29.         print('Возможно это ответ: ', A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement