Sequences, not combinations
transcript
Songs last two, three and four minutes. A drive is six minutes. Songs repeat. How many playlists fill it?
With songs outside, the table counts combinations. Two and four is one combination. With lengths outside, order counts. Two and four, and four and two, differ. So the table counts four.
Songs outside give three. Lengths outside give four. Same songs. Same drive.
With songs outside, two and four counts once. With lengths outside, two and four, then four and two. The inner loop picks the last song, so order shows.
Swap the loops. Items go in the outer loop. Test with a small input and count by hand. A minimum is the same either way.
Put the items in the outer loop. With the lengths outside, each order counts separately. A minimum does not care.
Choose the outer loop on purpose. Ask: do I count orders, or not? Most playlist questions ignore order. Full breakdown in the lecture.