Alternating Routes

Objective:

Make the train alternate between a straight and a left routes on a double loop track.

Sample Solution:

The double loop track used for this example has a small loop nested in a larger loop. When driving counter-clockwise, the train has a choice to take a left or go straight. This program alternates the route decisions using the modulo operation on the split counter variable. The train turns left when the split counter is an odd number and drives straight when it is even.