Skip to content

Instantly share code, notes, and snippets.

@mvidner
Created December 6, 2013 15:39
Show Gist options
  • Select an option

  • Save mvidner/7826710 to your computer and use it in GitHub Desktop.

Select an option

Save mvidner/7826710 to your computer and use it in GitHub Desktop.
Assist in finding a minimal spanning tree of diffs among 4 files
#!/usr/bin/env ruby
filenames = ARGV
# hardcoded for 4 vertices
def all_pairs(v)
[
[v[0], v[1]],
[v[0], v[2]],
[v[0], v[3]],
[v[1], v[2]],
[v[1], v[3]],
[v[2], v[3]]
]
end
all_diffs = all_pairs(filenames).map do |a, b|
`diff -u #{a} #{b}`
end
all_diffs.sort_by{|s| s.length}.each do |i|
puts i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment