Partially directed self-avoiding walk (source code)

= Partially directed self-avoiding walk

On the <square lattice>, a <self-avoiding walk> using north, east and west steps but no south steps. At each horizontal height, self-avoidance forces one monotone horizontal run. Conversely, such runs separated by north steps always give <self-avoiding walks>, because every new run is at a previously unvisited height.