0

A meander is a self-avoiding closed curve which intersects a line a number of times.
Your task is, given a (not necessarily Hamiltonian) self-avoiding walk on a lattice/grid, produce a meander a la the following:
Input
{{{3, 4}}, {1, 2}, {2, 6}, {6, 7}, {7, 3}, {3, 4}, {4, 8}, {8, 12}, {12, 11...