varios решения представлены https://www.hackingnote.com/en/python-challenge-solutions/level-19 http://www.pythonchallenge.com/pc/hex/idiot2.html