|
EXAMPLE
|
For n = 2, there is one Euler tour, (1,2,1), since (1,2,1) is cyclically equivalent to (2,1,2).
For n = 3, there are three Euler tours: (1,2,1,3,2,3,1), (1,2,3,1,3,2,1), (1,2,3,2,1,3,1).
|
|
PROG
|
(Python for n <= 5)
def A(n, w='12'):
if len(w) > n*(n-1): return 1
extensions = (w+t for t in '12345'[:n] if w[-1]!=t and w[-1]+t not in w)
return sum(A(n, z) for z in extensions)
|