Trains the technique from
LeetCode 91Decode WaysThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A colour lab keeps twenty-six swatches, numbered 1 through 26. When a batch is mixed, the machine punches the swatch numbers onto a paper tape one after another with no separator between them, so a batch of swatch 8 then swatch 15 comes out as the tape "815".
You are handed a finished tape as the digit string tape and have to work out how many batches could have punched it. A swatch number is punched with no padding, so no number on the tape may begin with 0, and every number must land in the range 1 to 26.
Return the count of batches that produce tape. Return 0 when the tape cannot have come from any batch.
Example 1
The tape splits as 2,6,1,3 or 26,1,3 or 2,6,13 or 26,13, so four batches fit.
Example 2
The middle 0 cannot stand alone and 90 is past 26, so nothing accounts for it.
Example 3
The trailing 0 has to join the 2 in front of it as 20, leaving 1,1,20 or 11,20.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_tape_readings(tape: str) -> int:public int countTapeReadings(String tape)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.