login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A321512 Characteristic function of the reverse in the shuffle (perfect faro shuffle with cut): 1 if the sequence of shuffles of n cards contains the reverse of the original order of cards, 0 if not. 2

%I #24 May 03 2023 15:03:28

%S 1,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,

%T 0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,

%U 0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1

%N Characteristic function of the reverse in the shuffle (perfect faro shuffle with cut): 1 if the sequence of shuffles of n cards contains the reverse of the original order of cards, 0 if not.

%C 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.

%H Antti Karttunen, <a href="/A321512/b321512.txt">Table of n, a(n) for n = 1..65537</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%e For example, for n = 4, we have the following sequence of shuffles:

%e c(1) = 1234 <- initial order of cards

%e c(2) = 2413

%e c(3) = 4321 <- here's the reverse of c(1)

%e c(4) = 3142

%e c(5) = 1234

%e Hence the characteristic function at n = 4 is 1.

%e For n = 5,

%e c(1) = 12345

%e c(2) = 24135

%e c(3) = 43215

%e c(4) = 31425

%e c(5) = 12345

%e Observe that for n = 5, there's no 54321 in the c(i) sequence, so the characteristic function at n = 5 is 0.

%o (Python)

%o for n in range(1, 101):

%o cards = [i for i in range(1, n + 1)]

%o reverse = cards[::-1]

%o shuffled = cards.copy()

%o reversein = False

%o for i in range(n):

%o evens = shuffled[1::2]

%o odds = shuffled[0::2]

%o shuffled = evens + odds

%o if shuffled == reverse:

%o reversein = True

%o print(n, int(reversein))

%o (PARI)

%o shuffle(v) = {my(h=#v\2); vector(#v, i, if(i<=h, 2*i, 2*(i-h)-1))};

%o 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)};

%o 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

%Y Cf. A024222, A123320, A049206, A321580.

%K nonn

%O 1

%A _Pedro Menezes_, Nov 11 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 07:55 EDT 2024. Contains 371769 sequences. (Running on oeis4.)