implements #solve! method and uses each_index instead of each_with_index