Simon-Kucher interview question

Python Program