Solution to find-digits problem