Remy José Cano on Wed, 23 May 2018 07:20:12 +0200

 Re: Fisher-Yates reverse shuffle is possible?

``` Hi,

With respect, if something like that were reversible, the undelying
process has not to do with randomness (a way of defining random is:
The lack of pattern at all).

Sorry, as far I know, the answer definitely is NO.

In other hand, please notice the code you pasted from Rosetta is NOT
optimal, and likely wrong due 1) to place a my() inside a loop, 2) By
desing, for using a forstep() where a for() suffices. 2.999999....) a
"};" instead of "}" followed by a line break.

Cheers,

Remy

P.S.: Always ensure anywhere wether a function named "random" uses a
provably random source of "entropy".

On 23/05/2018, chandra sekaran <sekar.bc@gmail.com> wrote:
> Fisher-Yates reverse shuffle is possible?
>
> Following PARI-GP code. from www.rosettacode.org
>
> FY(v)={
>   forstep(n=#v,2,-1,
>     my(i=random(n)+1,t=v[i]);
>     v[i]=v[n];
>     v[n]=t
>   );
>   v
> };
>
> (09:56) gp > FY(vector(10,i,i))
> %14 = [2, 10, 7, 4, 5, 1, 9, 8, 3, 6]
> (09:56) gp > FY(vector(10,i,i))
> %15 = [2, 8, 1, 5, 9, 3, 7, 4, 6, 10]
> (09:56) gp > FY(vector(10,i,i))
> %16 = [8, 7, 2, 5, 4, 10, 6, 9, 3, 1]
> (09:56) gp > FY(vector(10,i,i))
> %17 = [10, 4, 2, 5, 7, 3, 6, 9, 1, 8]
>
> Regards,
> Chandrasekaran B
>

--
_____________________________

Remy José Cano Ramírez
1-43 Entrada principal a Santa Juana. Mérida, ME 5101, Venezuela
Phone: +58 412 077 6 077;
Page: https://www.oeis.org/wiki/User:R._J._Cano
Email: cano.remy.jose@gmail.com

```