Skip to content

Instantly share code, notes, and snippets.

@venj
Created May 11, 2012 06:25
Show Gist options
  • Save venj/2657903 to your computer and use it in GitHub Desktop.
Save venj/2657903 to your computer and use it in GitHub Desktop.
find duplicate city name for me.
#!/usr/bin/ruby
#encoding=utf8
cities = {}
open("/Users/venj/Desktop/city.txt").each_line do |l|
city = l.split("=").last
if cities[city].nil?
cities[city] = 0
else
cities[city] += 1
end
end
cities.each do |key, value|
if value > 1
puts key
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment