It looks like the puzzle is to find an interleaving of execution that
makes sense.
Other than solving it by hand, one idea I have is to wrap around each
line of code some sort of error handler that keeps trying that line
until it succeeds. This should work if the puzzle has been designed
so that the interleaving can be found using a "greedy" method of
executing a line as soon as it becomes possible to do so.