Anagram Descrambler (in Swift!)

I got home late, but I still wanted to make something for NaCreSoMo today. I decided to write an anagram descrambler: give it two words with the same letters and it will map one to the other. Here it is descrambling a timely viral joke:

M E R R I C K   G A R L A N D
| | | | | | | | | | | | | | | 
\-+-+-+-+-+-+-+-+-+-+-+\| | | 
  \\| | | | | | | | | ||| | | 
   |\-+-+\| | | | | | ||| | | 
   |  \-+++-+-+-+-+-+-+++-+\| 
   |    \++\| | | | | ||| ||| 
   |     |\++\| | | | ||| ||| 
   |     | |\++\| | | ||| ||| 
   |     | | |\++\| | ||| ||| 
 /-+-----+-+-+-+/|| | ||| ||| 
 | |     | | | | |\-+\||| ||| 
 | |     | | | | |  \++++-+++\
 | |     | | | | | /-+/|| ||||
 | |     | | | | | | | |\\||||
 | | /---+-+-+-+-+-+-+-+-+/|||
 | | | /-+-+-+-+-+-+-+-+-+-+/|
 | | | | | | | | | | | | | | |
 G E N D R I C K   L A M A R R

I wrote it in Swift, which is the language I work on at Apple. Curiously, since I work on the language and its compiler, I don’t get much of a chance to actually write things in Swift besides test cases.

You can check out the whole source code (and try your own anagrams!) on IBM’s Swift Sandbox.