The rule that converts a 10-digit NDC to 11 digits by inserting a zero at the start of whichever segment is one digit short.
There are exactly three cases and no judgement involved once you know the source format. What makes it error-prone is that the source format is not stated anywhere on the package — it has to be inferred from the segment lengths.
Never pad by adding a zero to the front of the whole number, and never trim a digit to make the length fit. Both produce a code that will match a different product or fail validation.