Skip to main content
added 59 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 91 85 8484 82 bytes

Edit: -1 byte thanks to pajonk, then -2 bytes thanks to Giuseppe

function(v,l=sum(v|T),`?`=sample,m=(l:0)[!(02:(2^l-2)?1)%/%2^(0:l)%%2]){v[m]=v[?m];v}

Try it online!Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

R, 91 85 84 bytes

Edit: -1 byte thanks to pajonk

function(v,l=sum(v|T),`?`=sample,m=(l:0)[!(0:(2^l-2)?1)%/%2^(0:l)%%2]){v[m]=v[?m];v}

Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

R, 91 85 84 82 bytes

Edit: -1 byte thanks to pajonk, then -2 bytes thanks to Giuseppe

function(v,l=sum(v|T),`?`=sample,m=(l:0)[!(2:2^l-2?1)%/%2^(0:l)%%2]){v[m]=v[?m];v}

Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

added 48 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 91 8585 84 bytes

Edit: -1 byte thanks to pajonk

function(v,l=sum(v|T),s=sample`?`=sample,m=(l:0)[!s(0:(2^l-2),?1)%/%2^(0:l)%%2]){v[m]=v[s(m)];vv[m]=v[?m];v}

Try it online!Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

R, 91 85 bytes

function(v,l=sum(v|T),s=sample,m=(l:0)[!s(0:(2^l-2),1)%/%2^(0:l)%%2]){v[m]=v[s(m)];v}

Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

R, 91 85 84 bytes

Edit: -1 byte thanks to pajonk

function(v,l=sum(v|T),`?`=sample,m=(l:0)[!(0:(2^l-2)?1)%/%2^(0:l)%%2]){v[m]=v[?m];v}

Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

edited body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 9191 85 bytes

function(v,l=sum(v|T),s=sample){if(sum,m=(m<-l:0)[!s(0:(2^l-2),1)%/%2^(10:l-1)%%2)>1%%2])v[m]=s{v[m]=v[s(v[m]m);v];v}

Try it online!Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

R, 91 bytes

function(v,l=sum(v|T),s=sample){if(sum(m<-!s(0:(2^l-2),1)%/%2^(1:l-1)%%2)>1)v[m]=s(v[m]);v}

Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

R, 91 85 bytes

function(v,l=sum(v|T),s=sample,m=(l:0)[!s(0:(2^l-2),1)%/%2^(0:l)%%2]){v[m]=v[s(m)];v}

Try it online!

TIO link includes (reciprocal) distribution of shuffle_subsequence(1:3) to check conformity to tsh's calculations.

Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60
Loading