Related link: http://www.google.com/help/features.html#calculator

This morning, Adam Turoff pointed me toward a problem posed by Norman Walsh. He wanted to count the permutations of the middle letters of “morning”, figuring if we mistyped the word, we would at least get the first and last letters of the word right.

His solution was brute force: simply generate all the possibilities and count them. His solution is pretty ugly because it only works for a fixed number of letters.

This reminds me of statistical thermodynamics though. The number of distinct states is the factorial of the number of elements divided by the number of indistinct elements. In the letters in “ornin”, there are 5 ! states (120), but the “n” is duplicated, so there are two indistinct elements. The number of distinct states is then 120 / 2.

Adam tells me that factorials and morning coffee don’t mix though. Well, just google “ 5 ! / 2“.

Adam showed me that I could also get the result in roman numerals.