Wrote a better algorithm that should be unbeatable + tests