Brute-force solution for 246 but runs under a minute (maths were though for me on this one).