Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

rubyでビット文字列から'1'の位置を求める ref: http://qiita.com/items/0726851e110e2e356791

View scan_bits_index.rb
1 2
"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]
View scan_bits_index.rb
1 2
"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.