Skip to content

Instantly share code, notes, and snippets.

@alabamaair
Created May 18, 2016 15:42
Show Gist options
  • Save alabamaair/2ea8517d4d01a418a2d1386202560258 to your computer and use it in GitHub Desktop.
Save alabamaair/2ea8517d4d01a418a2d1386202560258 to your computer and use it in GitHub Desktop.
BinaryGap (Find longest sequence of zeros in binary representation of an integer) 80%score
def solution(n)
max = 0
temp = n.to_s(2).split(/1/)
temp.each do |x|
if max < x.size
max = x.size
end
end
return max
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment