faster problem 31