'Perplexing Puzzlers' for April Fool's Day
NPR Weekend Edition Sunday, April 1, 2007
Puzzle master Will Shortz quizzes:
Take the names of two U.S. States, mix them all together,
then rearrange the letters to form the names of two other U.S. States.
What states are these?
A Ruby solution a la brute force:
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"] for i in 0...50 for j in (i+1)...50 str = (states[i]+states[j]).downcase.split(//).sort.join for m in (i+1)...50 next if m == j for n in (m+1)...50 next if n == j next if str.length != (states[m]+states[n]).length alt = (states[m]+states[n]).downcase.split(//).sort.join puts "#{states[i]} + #{states[j]} = #{states[m]} + #{states[n]}" if str == alt end end end end
After a while it spits out:
North Carolina + South Dakota = North Dakota + South Carolina
Of course!