finished solving algorith