Hacker Rank : Find Digits : refactor