Let's solve this user's homework; I think it's an interesting exercise!
Input
Two 3-digit natural numbers.
Outputs
Two 2-digit numbers. In each of the output numbers, one digit is taken from one input number, and the other from the other number. The choice is independent. The first output number should be the minimal possible to create using these constraints, and the second one should be the maximal such number (or vice versa).
- Input numbers never have leading zeros; output numbers should also not have leading zeros.
- Input and output can be encoded as numbers, strings, lists of digits, etc.
Examples (in format input
- output
):
123, 912 - 11, 93
888, 906 - 68, 98
100, 100 - 10, 11
222, 222 - 22, 22
123, 222 - 12, 32
798, 132 - 17, 93
output numbers should also not have leading zeros
- but can an output be a single digit if the first digit is0
? Or can the output be just0
if both digits are? \$\endgroup\$123, 222
as a test case? My first attempt solved all the current cases but failed on this one, printing11 32
instead of12 32
. \$\endgroup\$798, 132
. The output should take 1 digit from each number, not two digits from same number. \$\endgroup\$