Trying to implement challenge 159 in C++ and not JS