https://www.yasu-p.com/entry/python-algorithm-1