Solving algorithm
.