simple C++ solution for 42