[3/3] Implement brute-force solver

Small code-cleanups and fix for a ugly leak