Maxie and Minnie

Published by yanni in

Maxie is the largest number that can be obtained by swapping two digits, Minnie is the smallest. Write a function that takes a number and returns Maxie and Minnie. Leading zeros are not permitted.

Examples

maxmin(12340) ➞ (42310, 10342)

maxmin(98761) ➞ (98761, 18769)

maxmin(9000) ➞ (9000, 9000)
# Sometimes no swap needed.

maxmin(11321) ➞ (31121, 11123)

Notes

N/A

Watch a quick demo on how Edabit works.