This is practically impossible to solve for anyone without a mathematics degree.
Unless you happen to realize/find it's the secretary problem, and then it's laughably easy. Basically it's either recognizing the problem, or good googling skills - not python skill.