Problem S.20 (Mathematical and Physical Journal for High Schools, Problem S.20.). See details here: https://www.komal.hu/feladat?a=feladat&f=S20&l=en. My solution uses a completely different method than the solution key. This program can be run in Python.