Thread Suche Algorithmus (5 answers)
Opened by mikdoe at 2007-08-13 11:18

renee
 2007-08-13 11:39
#98025 #98025
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl

use strict;
use warnings;
use Math::Combinatorics;

my @list = qw(Alpha Beta Caesar Delta);

for( 2 .. scalar(@list) ){
    my $comb = Math::Combinatorics->new(
        count => $_,
        data  => [@list],
    );
    
    while( my @perms = $comb->next_combination ){
        print join( ' ', @perms ), "\n";
    }
}


Ausgabe:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
C:\>combinatorics.pl
Alpha Beta
Alpha Caesar
Alpha Delta
Beta Caesar
Beta Delta
Caesar Delta
Alpha Beta Caesar
Alpha Beta Delta
Alpha Caesar Delta
Beta Caesar Delta
Alpha Caesar Beta Delta
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Suche Algorithmus