Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次の配列をサブ配列に分割して、1 の開始と終了時にサブ配列が開始および終了するようにします...
a=[1,1,0,0,1,0,1,1,1]
だから私はこれを新しい配列として終わらせます...
=> [[1,1],[1],[1,1,1]]
誰かアイデアがありましたか...?
a.join.split('0').select {|b| b if not b.empty?}.map {|c| c.split(//).map{|d| d.to_i}}