Skip to content

Instantly share code, notes, and snippets.

@chrisvaughn
Created May 24, 2018 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisvaughn/97221f05f25519cfe29f6469f80213c1 to your computer and use it in GitHub Desktop.
Save chrisvaughn/97221f05f25519cfe29f6469f80213c1 to your computer and use it in GitHub Desktop.
shifted_checkin = 0000100111011111, computed streak should equal 5
0. starting value
0000100111011111
1. invert (~shifted_checkin)
1111011000100000
2. compute "shifted_checkin + 1"
0000100111011111 + 1 = 0000100111100000
3. AND step 1 & 2 (~shifted_checkin & (shifted_checkin + 1))
1111011000100000 & 0000100111100000 = 0000000000100000 = 32
4. log2(32) = 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment