Exercise 1: All Three Non-Trivial Shorthand Forms — Possible Solution ==================================================================== THE TEST ------------------------------ expand_shorthand("4px 8px 12px 16px") expand_shorthand("3px 6px") expand_shorthand("20px") RESULT ------------------------------ "4px 8px 12px 16px" -> EdgeSizes(top=4, right=8, bottom=12, left=16) "3px 6px" -> EdgeSizes(top=3, right=6, bottom=3, left=6) "20px" -> EdgeSizes(top=20, right=20, bottom=20, left=20) WHY EACH ONE COMES OUT THIS WAY ------------------------------ 4-value form: the branch `t, r, b, l = lengths` unpacks the four values directly, in the exact order they were written -- top, right, bottom, left, reading clockwise starting from the top. No value is ever reused between sides in this form; all four can be, and here are, genuinely independent. 2-value form: `t = b = lengths[0]; r = l = lengths[1]` -- the first value is applied to BOTH top and bottom (the vertical pair), and the second value is applied to BOTH left and right (the horizontal pair). Only two independent numbers exist; opposite sides always match. 1-value form: `t = r = b = l = lengths[0]` -- a single number is applied to all four sides identically, the simplest and most restrictive case. WHICH FORM ALLOWS ALL FOUR SIDES TO GENUINELY DIFFER ------------------------------ Only the 4-value form. The 1-value form forces all four sides identical by construction. The 2-value form forces top==bottom and left==right -- at most two distinct numbers appear, and opposite sides are always locked together. Even the 3-value form (top, horizontal, bottom) still forces left==right, since the middle value is shared between them -- at most three distinct numbers, never four. Genuinely independent values on all four sides requires writing out all four explicitly. WHY THIS WORKS AS AN ANSWER ------------------------------ This confirms expand_shorthand's own branch-by-length-count structure directly encodes CSS's own real specification -- each shorthand length isn't an arbitrary convenience, it's a deliberate compression scheme that trades "how many independent values can this side have" against "how many numbers do I have to type," with the 4-value form being the only one that gives up none of that independence.