Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solution(N):
- max_gap=0
- current_gap=0
- while N>0 and N%2==0:
- #print([N,current_gap,max_gap,"{0:b}".format(N)])
- N//=2
- while N>0:
- if N%2==0:
- current_gap+=1
- else:
- if current_gap!=0:
- max_gap=max(current_gap,max_gap)
- current_gap=0
- #print([N,current_gap,max_gap,"{0:b}".format(N)])
- N//=2
- return max_gap
- solution(1042)
Add Comment
Please, Sign In to add comment