Solution to the commuting engineer problem in C++.