A more C++ 11 implementation of problem 10