Russell Gordon


01 October, 2020

    What this puzzle amounts to is drawing a "trident" (essentially a fork) using plain text.

    Read the problem description for a complete overview.

    When you run the code, you'll notice that the program is partially completed. We are prompted for the tine length and spacing between tines, and then the tines are drawn.

    How does that work, though? To understand this, we'll set a breakpoint and then use the Xcode debugger. Click beside line 30 in the source code. Then run the program and provide input for the tine length and spacing.

    The program will then pause, showing the next line to be executed, highlighted in green. We can use the step over button to run one line of code at a time:

    Stepping over an instruction using the Xcode debugger.

    As we step over the code, you'll notice the output appears in the bottom right corner, and that each loop does something a little different for us.

    The outer loop controls the vertical, ensuring the tines are long enough.

    Notice that if we hover our mouse pointer over a variable, in this case tineLength, the debugger tells us that the variable contains 5. So, the tines will be five stars long, vertically.

    The inner loops draw the horizontal – that is, the three tines and the space between the tines.

    As you try this out on your own computer, be sure to stop, then start the program and step through the code as many times as needed until you get a feel for what the code is doing.

    Your job is to add code as needed – more loops – after line 45 to draw the rest of the trident. Note that this code:

    print("*", terminator: "")

    ... draws a star to the screen, and by passing an empty string as the terminator, ensures the next character will be drawn on the same line.

    This code:


    ... while it appears very similar, will draw nothing to the screen, but because a terminator was not provided, Swift assumes that we want the next character, when it is drawn, to be placed on a new line.

    Understanding that difference is key to solving this puzzle. Good luck! Have fun! 😎