Technoblade777

Foxford 22

Apr 8th, 2022 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def Bin(N):
  2.     s = ''
  3.     while N > 0:
  4.         s = str(N) + s
  5.         N = N // 2
  6.     return s
  7. def antiBin(N):
  8.     R = 0
  9.     for i in range(len(N)):
  10.         R += int(N[i])*2**(int(len(N))-i-1)
  11.     return R
  12.  
  13. def f(N):
  14.     ns = Bin(N)
  15.     N = Bin(N)
  16.     N = list(N)
  17.     a = len(N)
  18.    
  19.     N.append(N[a-1])
  20.    
  21.     if ns.count('1') % 2 == 0:
  22.         N.append('0')
  23.     elif ns.count('1') % 2 != 0:
  24.         N.append('1')
  25.    
  26.    
  27.     if N.count('1') % 2 != 0:
  28.         N.append('1')
  29.    
  30.        
  31.     R = antiBin(N)
  32.     return R
  33.  
  34. for i in range(1, 10000):
  35.     if f(i) > 160:
  36.         print(i)
  37.         break
Add Comment
Please, Sign In to add comment