Skip to content

Instantly share code, notes, and snippets.

@mawaldne
Created January 2, 2015 00:06
Show Gist options
  • Save mawaldne/34d7dd9977b9fbe65473 to your computer and use it in GitHub Desktop.
Save mawaldne/34d7dd9977b9fbe65473 to your computer and use it in GitHub Desktop.
[2014-12-28] Challenge #195 [Easy] Symbolic Link Resolution
# run as: ruby sym_link_reso.rb input.txt
lines = open(ARGV[0]).readlines
directory = lines.last
symlinks = lines[1..-2].each_with_object({}) do |line, hash|
symlink = line.chomp.split(':')
hash[symlink[0].chomp("/")] = symlink[1].chomp("/")
end
while symlinks.keys.any? { |symlink| directory.include?(symlink) } do
symlinks.each do |key, value|
directory.gsub!(key, value)
end
end
puts directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment