Smallest Divisible Digit Product I
Real-world version: Next Shelf LabelThe statement here is our own: the same inputs, outputs and technique.
A stockroom numbers its shelves with positive whole numbers. A shelf label is valid for a crate of type t when the product of the label's decimal digits is a multiple of t.
The next free shelf is n, and the crate may be placed on shelf n or on any higher-numbered shelf. Return the smallest label at or above n that is valid for t.
A label containing the digit 0 has a digit product of 0, and 0 counts as a multiple of every positive t.
Examples
Example 1
- Input
- n = 15, t = 7
- Output
- 17
Shelf 15 has digit product 5 and shelf 16 has digit product 6, neither of which is a multiple of 7. Shelf 17 has digit product 7.
Example 2
- Input
- n = 16, t = 10
- Output
- 20
Shelves 16 through 19 have digit products 6, 7, 8 and 9. Shelf 20 has digit product 0, which counts as a multiple of 10.
Example 3
- Input
- n = 99, t = 9
- Output
- 99
Shelf 99 has digit product 81, and 81 is 9 times 9.
Constraints
- 1 <= n <= 100
- 1 <= t <= 10
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 smallest_shelf_label(n: int, t: int) -> int:public int smallestShelfLabel(int n, int t)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 14 test cases: 14 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
More on the same topics
- Count Square Sum TriplesReal-world version: Triples of Squares That Add UpEasy
- Count PrimesReal-world version: Indivisible Catalogue NumbersMedium
- Total Waviness of Numbers in Range IReal-world version: Serial Number KinksMedium
- Reordered Power of 2Real-world version: Rearranging the Digits Into a Power of TwoMedium