Say you need to determine what you will drink with your meals at home tomorrow. There are two meals, breakfast
and dinner
. And you have three options of drink for each meal: milk
, water
, and beer
.
Now, this is the same as having a function
$f\colon\{$ breakfast
, dinner
$\}\to\{$ milk
, water
, beer
$\}$.
How many different combinations of drinks can you have? It's more than $2\times 3=6$ combinations; it's $3^2=9$ combinations:
- Milk at both breakfast and dinner;
- Milk at breakfast, water at dinner;
- Milk at breakfast, beer at dinner;
- Water at breakfast, milk at dinner;
- Water at both breakfast and dinner;
- Water at breakfast, beer at dinner;
- Beer at breakfast, milk at dinner;
- Beer at breakfast, water at dinner;
- Beer at both breakfast and dinner.
As you see: three choices for what to do for breakfast, and three choices for what to do at dinner, for a total of $3\times 3 = 3^2$ possible outcomes.
If you had to plan for $N$ different meals, and you had $M$ choices for each meal? $M$ possible choices for the first, $M$ possible choices for the second, and so on. In the end, do you have $N\times M$, or do you have $M^N$?