Made a draft of the solving algo. It compiles but is incomplete.