public
Created

Ruby thingy

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10
list = [['A', 'B', 'C'], ['A', 'C', 'E'], ['E', 'F', 'D'], ['D', 'A', 'J'], ['E', 'D', 'J']]
freq = {}
list.each do |seq|
seq.combination(2).each do |combo|
freq[combo.sort] = (freq[combo.sort] || 0) + 1
end
end
freq.keys.sort.each do |key|
puts "#{key.join(', ')}, #{freq[key]}"
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.