Solver bug fix

Fixed a bug where the brute force method would overwrite values that
should not have been changed. Added a boolean matrix to fix this issue.