DWITE 2011-07 P3: Optimized code for clarity using a less elegant approach to combinatorics.