Skip to content

Instantly share code, notes, and snippets.

@MelanieS
Created July 27, 2011 05:32
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 MelanieS/1108745 to your computer and use it in GitHub Desktop.
Save MelanieS/1108745 to your computer and use it in GitHub Desktop.
Keyword list maker
puts "Please enter a keyword to go with your 50 states"
keyword = gets.chomp
puts "Would you like your keyword to go before (b) or after(a) your state?"
answer = gets.chomp
states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado",
"Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho",
"Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana",
"Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota",
"Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
"New Hampshire", "New Jersey", "New Mexico", "New York",
"North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon",
"Pennsylvania", "Rhode Island", "South Carolina", "South Dakota",
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington",
"West Virginia", "Wisconsin", "Wyoming"]
if answer == "a"
new_keywords = states.map { |e| "#{e} #{keyword}"}
elsif answer == "b"
new_keywords = states.map { |e| "#{keyword} #{e}"}
end
keyword_file = File.new("#{keyword}.out", "w")
keyword_file.puts new_keywords
keyword_file.close
puts "Your file has been created."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment