hdarwin

cstutoringcenter.com_Adjacent Bit Count I

Jan 18th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. g = (x for x in xrange(1,10**7+1))
  2. sum = 0
  3. for x in g:
  4.     x = bin(x)[2:]
  5.     s = 0
  6.     for y in xrange(0,len(x)-1):
  7.         if( x[y:y+1] == '1' and x[y+1:y+2] == '1' ): s+=1
  8.     if s == 5:
  9.         sum += 1
  10. print sum
Advertisement
Add Comment
Please, Sign In to add comment