This one is rather inefficient, but would have worked as there's no weird turns that would result in this misfiring in my input.
This one is somehow more inefficient, but would still technically work.
This one manages to be the most efficient one and the easiest one to do conceptually. Note that segments grazing the edge are fine - in fact, some are guaranteed because of the corners.