Skip to content

Instantly share code, notes, and snippets.

@schrockwell
Created May 1, 2012 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schrockwell/2571329 to your computer and use it in GitHub Desktop.
Save schrockwell/2571329 to your computer and use it in GitHub Desktop.
Ruby thingy
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment