OFFSET
1
COMMENTS
The characteristic function of A321580: 1 if in the sequence of Faro's shuffle of n cards there is at some point the exact reverse of the initial order (the cards are backwards); 0 if not.
LINKS
EXAMPLE
For example, for n = 4, we have the following sequence of shuffles:
c(1) = 1234 <- initial order of cards
c(2) = 2413
c(3) = 4321 <- here's the reverse of c(1)
c(4) = 3142
c(5) = 1234
Hence the characteristic function at n = 4 is 1.
For n = 5,
c(1) = 12345
c(2) = 24135
c(3) = 43215
c(4) = 31425
c(5) = 12345
Observe that for n = 5, there's no 54321 in the c(i) sequence, so the characteristic function at n = 5 is 0.
PROG
(Python)
for n in range(1, 101):
cards = [i for i in range(1, n + 1)]
reverse = cards[::-1]
shuffled = cards.copy()
reversein = False
for i in range(n):
evens = shuffled[1::2]
odds = shuffled[0::2]
shuffled = evens + odds
if shuffled == reverse:
reversein = True
print(n, int(reversein))
(PARI)
shuffle(v) = {my(h=#v\2); vector(#v, i, if(i<=h, 2*i, 2*(i-h)-1))};
permcycs(v) = {my(f=vector(#v), L=List()); for(i=1, #v, if(!f[i], my(T=List(), j=i); while(!f[j], f[j]=1; listput(T, j); j=v[j]); listput(L, Vec(T)))); Vec(L)};
A321512(n)={my(v=permcycs(shuffle([1..n])), e=-1); for(k=1, #v, my(p=v[k]); if(#p>1||n%2==0||2*p[1]<>n+1, my(h=#p\2); if(e<0, e=valuation(#p, 2)); if(valuation(#p, 2)<>e || e==0 || p[1..h]+p[h+1..2*h]<>vector(h, i, n+1), return(0)))); 1}; \\ This is Andrew Howroyd's Nov 13 2018 code for the characteristic function of A321580, given under that entry with the name "ok". Copied here by Antti Karttunen, Dec 06 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Pedro Menezes, Nov 11 2018
STATUS
approved