Practical Golf - US States
Ruby

Thought it would be interesting to extract the state abbreviations without writing any of the names or abbrevations explicitly. This one does not take misspelling of the input into consideration, because we don't care about such thing here on codegolf.SE, rihgt?

def f(s)
  [
    /(.).* (.)/,              # two words
    /^([CDGHKLPV]).*(.)$/,    # first and last letter
    /^(.).*([ZVX])/,          # unique letter
    /^([NFOUW])(.)/,          # two first letters
    /^(.)([DNR])/,            # unique second letter
    /^(.).*(L|N)\2/,          # double letters
    /^(.).SS(A|O)/,           # double S before the one used
    /^(.).*?[SNW](.)/,        # identified by the letters before them
    /(.)(.)/                  # two first letters

  ].find { |r| r =~ s.upcase }
  $1+$2
end


It took a conciderable time to figure out clever patterns to match all the states. The order of the patterns is important -- each consecutive pattern applies to the remaining states that were not matched by a previous pattern:

All states with two words in them use the initial letters of the two words:


  New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Rhode Island, South Carolina, South Dakota, West Virginia


All states beggining with any letter in {CDGHKLPV} use the first and last letter in the name:


  California, Colorado, Connecticut, Delaware, Georgia, Hawaii, Kansas, Kentucky, Louisiana, Pennsylvania, Virginia, Vermont


Of the remaining states, the letters {ZVX} are unique:


  Arizona, Nevada, Texas


All remaining states beginning with {FNOUW} use the two first letters.


  Florida, Nebraska, Ohio, Oklahoma, Oregon, Utah, Washington, Wisconsin, Wyoming


Then, {DNR} are unique as second letters:


  Arkansas, Indiana, Idaho


It's really getting hard to make general patterns, but...

Only three remaining states use double N or L, and the double letter is used in the state abbreviation:


  Tennessee, Minnesota, Illinois


A or O after double S is unique to


  Massachusetts and Missouri


Whenever {SNW} appear before other letters in the remaining state names, the letters after them are used in the abbreviations:


  Alaska, Maryland, Maine, Mississippi, Montana, Iowa


Two left. These use the two first letters:


  Alabama, Michigan




It can be golfed of course:

Ruby 2 – 191 165 154 characters

Another 26 characters off by uglifying the regexes a bit. Also, one of the original regexes turned out to be redundant!

gets;[/.* (.)/,/^[CDGHKLPV].*(.)$/,/.*([ZVX])/,/^[NFOUW](.)/,/^.([DNR])/,/.*(L|N)\1/,
/.*SS(A|O)/,/.*?[SNW](.)/,/.(.)/].find{|r|$_.upcase=~r}
puts $&amp;[0]+$1