When I tried to post an answer with the following content:
ha = a.group_by(&:itself).map{|k, v| [k, v.length]}.to_h
hb = b.group_by(&:itself).map{|k, v| [k, v.length]}.to_h
ha.merge(hb){|_, va, vb| (va - vb).abs}.inject([]){|a, (k, v)| a << [k] * v}.flatten
the post was automatically changed to:
group_by(&:itself).map{|k, v| [k, v.length]}.to_h hb = b.group_by(&:itself).map{|k, v| [k, v.length]}.to_h ha.merge(hb){|_, va, vb| (va - vb).abs}.inject([]){|a, (k, v)| a << [k] * v}.flatten
That is, the code formatting with four spaces before each line was removed, and the initial ha = a.
was also trimmed.
gimmehtehcodezpls
;)