randRange(0,11) ["CLAW", "OPAL", "APE", "RULES", "ANGER", "SLIME", "FEAT", "FANCY", "SONG", "DEN", "TIGER", "IRON"][INDEX] shuffle(WORD).join("") factorial(WORD.length)

How many unique ways are there to arrange the letters in the word WORD?

ANSWER

Let's try building the re-arrangements (or permutations) letter by letter. The word is WORD.length letters long:

_.map(_.range(WORD.length), function(l){ return "_ "; }).join("")

Now, for the first blank, we have WORD.length choices of letters to put in.

After we put in the first letter, let's say it's PERM[0], we have WORD.length-1 blanks left.

PERM[0]+" "+_.map(_.range(WORD.length-1), function(l){ return "_ "; }).join("")

For the second blank, we only have WORD.length-1 choices of letters left to put in. So far, there were WORD.length \cdot WORD.length-1 unique choices we could have made.

We can continue in this fashion to put in a third letter, then a fourth, and so on. At each step, we have one fewer unique choice to make, until we get to the last letter, and there's only one we can put in.

So, the total number of unique re-arrangements must be _.map(_.range(WORD.length).reverse(), function(l){ return (++l);}).join("\\cdot"). Another way of writing this is WORD.length!, or WORD.length factorial, which is ANSWER.
randRange(4,5) _.map(randRangeUnique(0,8,NUM_NAMES), function(n){ return ["Bloopin", "Gloopin", "Prancer", "Lancer", "Quentin", "Balthazar", "Ezekiel", "Jebediah", "Rudy"][n]; }) randRange(3, NAMES.length-1) factorial(NAMES.length)/factorial(NAMES.length-SLOTS)

You have NAMES.length reindeer, toSentence(NAMES), and you want to have SLOTS fly your sleigh. You always have your reindeer fly in a single-file line.

How many different ways can you arrange your reindeer?

ANSWER

We can build our line of reindeer one by one: there are SLOTS slots, and we have NAMES.length different reindeer we can put in the first slot.

Once we fill the first slot, we only have NAMES.length-1 reindeer left, so we only have NAMES.length-1 choices for the second slot. So far, there are NAMES.length \cdot NAMES.length-1 = NAMES.length*(NAMES.length-1) unique choices we can make.

We can continue in this way for the third reindeer, and so on, until we reach the last slot, where we will have NAMES.length - SLOTS + 1 choices for the last reindeer.

So, the total number of unique choices we could make to get to an arrangement of reindeer is _.map(_.range(SLOTS), function(l){ return (NAMES.length - l);}).join("\\cdot"). Another way of writing this is \dfrac{NAMES.length!}{(NAMES.length-SLOTS)!} = ANSWER