๐ WAYPOINT LESSON
The Tight Walk
โญโญโญ advancedโณ 30 min read๐ Lesson 157 of 281
Fix the high digits to N's prefix, branch below the boundary digit, and the suffix becomes a free combinatorial count.
Walking the boundary
To count x in [1, N] with property P, walk N's digits left to right. At position i, every x whose first i digits match N's prefix is "tight"; choosing any digit below N's digit there breaks tightness forever, and the remaining suffix is FREE: any combination of digits is allowed, so the count is a precomputed table, not a search.
The tight chain dies the moment you pick d < lim โ that one-way door is the whole structure of digit DP.