in reply to Algorithm RFC: fast (pseudo-)random shuffle with no repetition
What is actually against calculating the valid permutations in advance? A try:
#!/usr/bin/env perl use strict; use warnings; use Algorithm::Permute; use feature qw(say); use Data::Dump; my $n = [ 1, 2, 3, 3, 3, 4, 8 ]; my $p = Algorithm::Permute->new($n, 7); my $m3 = qr/(.)\1\1/; my $m2 = qr/(.)\1/; my @v; while ( my @r = $p->next ) { my $s = pack( "(A*)*", @r ); next if $s =~ /$m3/; next if $s =~ /$m2/; push( @v, $s ); } dd \@v; __END__
«The Crux of the Biscuit is the Apostrophe»
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Algorithm RFC: fast (pseudo-)random shuffle with no repetition
by LanX (Saint) on Sep 23, 2023 at 21:28 UTC | |
by karlgoethebier (Abbot) on Sep 24, 2023 at 09:42 UTC | |
by LanX (Saint) on Sep 24, 2023 at 12:28 UTC | |
by karlgoethebier (Abbot) on Sep 24, 2023 at 14:09 UTC | |
by LanX (Saint) on Sep 24, 2023 at 14:31 UTC | |
|