Brute force + fast solution for p5