in reply to Re^8: Algorithm RFC: fast (pseudo-)random shuffle with no repetition
in thread Algorithm RFC: fast (pseudo-)random shuffle with no repetition

karl@h3002993:~/src/perl$ time ./pmute.pl 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 real 0m0,064s user 0m0,044s sys 0m0,005s

«The Crux of the Biscuit is the Apostrophe»

  • Comment on Re^9: Algorithm RFC: fast (pseudo-)random shuffle with no repetition
  • Download Code

Replies are listed 'Best First'.
Re^10: Algorithm RFC: fast (pseudo-)random shuffle with no repetition
by LanX (Saint) on Sep 24, 2023 at 19:09 UTC
    The 15 came from the OP,

    But as I said

    > If this doesn't convince you that try-and-error isn't a good idea, try adding even more 1s and 2s.

    for instance ((1)x 51, (2) x 50)

    ==>

    ((101!) / (51!)) / (50!) = 1.99804427433e+29

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

      There is nothing I have to be convinced of. It was clear that with this method at some point end is. With ((1)x 9, (2) x 8) the red area begins on the relatively weak machine on which I tried this via IPad/SSH: 0m0,003s in the best and 0m41,493s in the worst case so far. With ((1)x 51, (2) x 50) that's completely hopeless there. With the OP's example (15), the result was actually quite acceptable - unlike what he expected predicted by him.

      «The Crux of the Biscuit is the Apostrophe»