Digit dynamic programming (source code)

= Digit dynamic programming

= digit DP
{synonym}

Count or sum <integers> by processing their <numerical digits> and merging prefixes that have the same possible continuations. Typical state records include the current position, whether the prefix still equals an upper limit, a <remainder>, or a <bit mask> of digits already used. The final answer comes from accepting exactly those states satisfying the desired digit constraints.