The lid of a puzzle box is engraved with a number p. The code that opens it is the
smallest positive integer whose digits multiply to exactly p. For example, the digits of
78 multiply to 7 * 8 = 56, and no smaller positive integer does, so for p = 56 the code is
78.
Write box_code(p) that returns the code as an integer, or -1 if no positive integer has
digits whose product is p.
Examples
Input: p = 56
Output: 78
Input: p = 150
Output: 556
Input: p = 13
Output: -1
Input: p = 0
Output: 10
Constraints
0 <= p <= 10**18
Goals
- Break a number into single-digit factors
- Argue why a greedy order gives the smallest number
- Treat 0 and 1 as special cases