Order fragments by their joins
transcript
You have two fragments, three and thirty. Join them to print the largest code. Sorting looks easy. Which one goes first?
Sorted as text, thirty comes before three. Joined, that prints three hundred and three. Three first prints three hundred and thirty. Three thirty is the larger code.
For two fragments, join a then b. Then join b then a, and compare. Put the fragment with the larger join first. The fragments alone never decide the order.
Some fragments tie under that rule. Three, thirty-three and three thirty-three all tie. All six orders print the very same code. So the problem counts orders, not codes.
Count the best orders with factorials. A tied run of three gives six orders. A tied run of two gives two orders. Multiply the counts across the tied runs.
Never sort these fragments as plain text. Compare the two joins of every pair. Full breakdown in the lecture.