Use iterators in `merge_solution` instead of using counter
variables to keep track of the next element to be taken out
from `params` and `solution`.