Bulls and Cows

Try to solve the Bulls and Cows problem.

Statement

You are playing a number guessing game called “Bulls and Cows” with a friend.

You write down a secret number, and your friend tries to guess it. ...