Python implementation solving https://github.com/eatnumber1/goal