how can i find the non-self-intersecting loop that uses the least amount of straight lines (curves left/right as often as possible every turn) and still loops back on itself?

Heres an example we have calculated for 8x8:
[Image][1]

Here is an example we have calculated for a 6x6:
[Image][2]


  [1]: https://i.sstatic.net/phi9Q.png
  [2]: https://i.sstatic.net/AMSVj.png