Thread String wieder zufällig zusammenfügen?
(7 answers)
Opened by Saugwels98 at 2013-09-22 18:15
So ein Sonntag ist doch was Feines :) :
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #!/usr/bin/perl use warnings; use strict; use List::Util 'shuffle'; my $a = "KAMEL"; my @b = split("", $a); my %c; my $x = 0; my $n = 0; while ($x < 1000) { @b = shuffle(@b); my $s = join("", @b); if (exists($c{$s})) { $x++; } else { $c{$s} = ""; $x = 0; $n++; } } my @e = sort(keys(%c)); foreach my $i (@e) { print "$i\n"; } print "$n permutations, probably all.\n"; Last edited: 2013-09-22 20:03:34 +0200 (CEST) |