Skip to content

@noriaki /scan_bits_index.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
rubyでビット文字列から'1'の位置を求める ref: http://qiita.com/items/0726851e110e2e356791
"10100100110".reverse.split('1',-1).inject([]){|ret,i| ret << i.size + (ret.last.nil? ? 0 : ret.last + 1); ret }[0..-2]
# => [1, 2, 5, 8, 10]
"10100100110".split('1',-1).inject([]){|ret,i| ret << i.size + (ret.last.nil? ? 0 : ret.last + 1); ret }[0..-2]
# => [0, 2, 5, 8, 9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.