solving problems with algorithm