So much better for you to solve it yourself but here's the simple logic with no code:
The game basically says that the answers to all 5 questions must be yes or no. There exists a certain series of yes or no for which minimum passwords are available.
I really hope you had to click read more to see this and did not get spoiled but here goes:
To minimise the 10,000 possibilities immediately, knowing the digits immediately removes many possibilities.
If we first assume The first three digits are 1,2,3 then the only possible outcomes are 1237, 1238, and 1239
But that's 3 outcomes so let's try another way. Let's assume first digit is not 1 but second and third are still 2 and 3.
Then there can be 5 possibilites for the first digit being even and 4 being odd(as it is not 1)
Therefore, assume it to be odd to mimimise possibilities.
Let us take first digit as 3, then the first 3 digits are 323 which add up to 8, therefore if the answers to the questions are no,yes,yes,no,yes; the only possible answer is 3239