Skip to content

Instantly share code, notes, and snippets.

@drpowell
Created June 3, 2011 03:07
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 drpowell/1005798 to your computer and use it in GitHub Desktop.
Save drpowell/1005798 to your computer and use it in GitHub Desktop.
Tom's coding challenge
module Library
def self.leaf_paths_of(paths)
normalized = paths.map {|s| x=s.squeeze('/'); x+='/'}
leafs = normalized.reject { |x| normalized.any? { |a| x != a && a.start_with?(x) } }
leafs.map {|x| x.chomp('/') }.uniq
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment