Multiply Strings
Real-world version: Punched Reel ProductThe statement here is our own: the same inputs, outputs and technique.
A stock-take terminal reads tallies off punched paper reels. A reel is written as a run of digit characters, heaviest digit first, and a reel can hold far more digits than any number type on the terminal can carry.
You are handed the reels left_reel and right_reel. Punch and return the reel that records their product. The digits are all you get to work with: feeding either reel into a built-in numeric type, or handing the job to a big-number library, is not allowed.
A reel never starts with a padding zero, the one exception being the single-digit reel "0", which stands for an empty tally. Your answer must obey the same rule.
Examples
Example 1
- Input
- left_reel = "47", right_reel = "206"
- Output
- "9682"
Column by column, 47 punched 206 times over lands on 9682, and no padding zero is needed in front.
Example 2
- Input
- left_reel = "70", right_reel = "30"
- Output
- "2100"
70 punched 30 times over lands on 2100. The trailing zero of each reel carries through to the answer, and no padding zero is written in front of it.
Example 3
- Input
- left_reel = "0", right_reel = "5814"
- Output
- "0"
An empty tally on one reel empties the product, and the answer is punched as the single digit 0 rather than a run of zeros.
Constraints
- 1 <= left_reel.length, right_reel.length <= 200
- left_reel and right_reel hold digit characters only
- Neither reel starts with a zero unless the reel is exactly "0"
The signature
The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def reel_product(left_reel: str, right_reel: str) -> str:public String reelProduct(String leftReel, String rightReel)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 11 test cases: 11 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's