ported problem 2 from C++, general file updates.