trying (in vain) to understand whichWays.cpp