Improved the mastermind (question 9 of TD3).