This program will compute the total distance an object is moved. It will then compute the rewards for moving that object based on the distance moved.
Get the starting position in cubits, palms and fingers. Get the ending position in cubits, palms and fingers. Convert each to fingers using the ToFingers sub algorithm. Reduce each using the Reduce sub algorithm Print starting and ending positions. Subtract startingFingers from endingFingers to make fingersMoved Reduce fingersMoved Print results. // Sub Algorithm Reduce // input fingers, palms, cubits // output newFingers, newPalms, newCubits // // Note this is all equations, it is ok to be in c++ like code here newFingers = fingers % FINGERS_PER_PALM newPalms = palms + fingers/FINGERS_PER_PALM newCubits = cubits + newPalms/PALMS_PER_CUBIT newPalms = newPalms % PALMS_PER_CUBIT // Sub Algorithm To Fingers // input fingers palms and cubits // output total fingers totalFingers = cubits * PALMS_PER_CUBIT * FINGERS_PER_PALM + palms * FINGERS_PER_PALM + fingersNote: In the end, I will do all computations in fingers. This way I don't need an IF statement or a loop. Note: I really don't need to provide details on input and output. Just note that it is performed unless there is something tricky.