Don't use nub.
Avoid sorting digits.