Took me a while, but the algo to beat the game is extremely simple :)