Skip to content

Instantly share code, notes, and snippets.

@bogardpd
Created July 8, 2018 23:33
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 bogardpd/58df3d9e1f749d42523c4ee30ee73fe1 to your computer and use it in GitHub Desktop.
Save bogardpd/58df3d9e1f749d42523c4ee30ee73fe1 to your computer and use it in GitHub Desktop.
state_codes = %w(AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY)
state_codes.sort!
one_letter_changes = Hash.new()
state_codes.each do |sc|
one_letter_changes[sc] = state_codes.select{|s| sc != s && (sc[0] == s[0] || sc[1] == s[1])}
puts "#{sc}: #{one_letter_changes[sc].join(", ")}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment