basically, for every digit, there are four choices at most. A direct method is just to try every possible combination. At most, you have to try 4 * 4 * 4 * 4 = 256 times, which are not very large. Hence, exploring all possible combinations is a feasible way.