mod: refactored task-13.cpp