fork download
  1. f=->a{c=Hash.new 0
  2. r=[[]]
  3. a.map{|e|2==(c[e]+=1)?r<<[]:r[-1]<<e}
  4. r}
  5.  
  6. input = [2, 1, 1, 2, 3, 2, 2, 4, 5, 6, 7, 3, 7, 0, 5]
  7.  
  8. p f[input]
Success #stdin #stdout 0.01s 7456KB
stdin
Standard input is empty
stdout
[[2, 1], [], [3, 2, 2, 4, 5, 6, 7], [], [0], []]