Infinite Snake is just like the video game Snake, except for that the snake is infinitely long, there are no items to eat, and the Snake needs to move in a repeating n
-step move pattern (e.g. right, up, right, up, right, down). The only constraint is that you can't crash back into yourself.
Challenge
Your goal is to write code that counts the number of valid move patterns of length n
, where two patterns are considered the same if you can get from one to the other through a series of rotations, reflections, and reversals.
This is a code-golf challenge, so the shortest code in bytes wins.
Origin
This sequence is based on the On-Line Encyclopedia of Integer Sequence's lastest "nice" sequence, A334322.
Number of endless self-avoiding walks of length n for the square lattice.
An "endless self-avoiding walk" (i.e., valid move pattern) is defined in the paper Endless self-avoiding walks by Nathan Clisby on the arXiv. Roughly speaking, an \$n\$-step self-avoiding walk (in the usual sense) is called endless if you can concatenate it with itself head-to-tail an infinite number of times and remain self-avoiding.
Example
For example, Figure 2.1 in the paper gives an example of an endless self-avoiding walk (of length six) on the left and a non-example on the right.
Small test cases
f(1) = 1:
---->
f(2) = 2:
---->----> and ---->
|
v
f(3) = 3:
---->---->---->, ---->---->, and ---->
| |
v v---->
f(4) = 7:
---->---->---->---->, ---->---->---->, ---->----> ,
| |
v v---->
---->---->, ----> ^, ----> , and ----> .
| | | | |
v v----> v----> v
| | |
v v v---->
More small values:
f(5) = 16
f(6) = 39
f(7) = 96
f(8) = 245
f(9) = 631
f(10) = 1642
n
given arbitrary RAM and time. \$\endgroup\$