Better solution to "toy robot" coding exercise (still in C++ though)