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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Bsp. 1)
n=5 a2 b3 c4 d3 = 72 (72/n = anzahl pro n (14,4))
n1) 1-1 1-1 1-4 1-3 = 12 +1 RE
n1) 1-1 2-2 1-1 1-2 = 2 n1) von 1 1 1 1 bis 1 2 1 2 ?
n2) 1-1 2-2 1-1 3-3 = 1 +1 RE
n2) 1-1 2-2 2-4 1-3 = 9
n2) 1-1 3-3 1-1 1-3 = 3
n2) 1-1 3-3 2-2 1-1 = 1 n2) von 1 2 1 3 bis 1 3 2 1 ?
n3) 1-1 3-3 2-2 2-3 = 2
n3) 1-1 3-3 3-4 1-3 = 6
n3) 2-2 1-1 1-2 1-3 = 6 n3) von 1 3 2 2 bis 2 1 2 3 ?
n4) 2-2 1-1 3-4 1-3 = 6
n4) 2-2 2-2 1-2 1-3 = 6
n4) 2-2 2-2 3-3 1-2 = 2 n4) von 2 1 3 1 bis 2 2 1 2
n5) 2-2 2-2 3-3 3-3 = 1
n5) 2-2 2-2 4-4 1-3 = 3
n5) 2-2 3-3 1-3 1-3 = 9
n5) 2-2 3-3 4-4 1-1 = 1 n5) von 2 2 3 3 bis 2 3 4 1
RE) 2-2 3-3 4-4 2-3 = 2 (2 3 4 2 und 2 3 4 3)
+ ----
72
----------------------------------------------------------------------------
Bsp. 2)
n=5 a2 b3 c4 = 24 (24/n = anzahl pro n (4,8))
n1) 1-1 1-1 1-4 = 4 + 1RE
n2) 1-1 2-2 1-4 = 4 + 1RE
n3) 1-1 3-3 1-4 = 4 + 1RE
n4) 2-2 1-1 1-4 = 4 + 1RE
n5) 2-2 2-2 1-4 = 4
RE) 2-2 3-3 1-4 = 4 //Rest wird anschließend auf n verteilt
----------------------------------------------------------------------------
Bsp. 3)
n=3 a2 b3 c4 d3 = 72 (72/n = anzahl pro n (24))
n1) 1-1 1-2 1-4 1-3 = 24
n2) 1-1 3-3 1-4 1-3 = 12
n2) 2-2 1-1 1-4 1-3 = 12 n2) von 1 3 1 1 bis 2 1 4 3
n3) 2-2 2-3 1-4 1-3 = 24
----------------------------------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl -w
use strict;
my $i = 0;
for my $w (1..2) {
for my $x (1..3) {
for my $y (1..4) {
for my $z (1..3) {
$i++;
print "$w $x $y $z\n";
}
}
}
}
print $i ."\n";
1
2
3
4
5
6
n=3 a2 b3 c4 d3 = 72 (72/n = anzahl pro n (24))
n1) 1-1 1-2 1-4 1-3 = 24
n2) 1-1 3-3 1-4 1-3 = 12
n2) 2-2 1-1 1-4 1-3 = 12 n2) von 1 3 1 1 bis 2 1 4 3
n3) 2-2 2-3 1-4 1-3 = 24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl -w
use strict;
my $i = 0;
for my $w (1..1) {
for my $x (1..2) {
for my $y (1..4) {
for my $z (1..3) {
$i++;
print "$w $x $y $z\n";
}
}
}
}
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 -w
use strict;
my $i = 0;
for my $w (1..1) {
for my $x (3..3) {
for my $y (1..4) {
for my $z (1..3) {
$i++;
print "$w $x $y $z\n";
}
}
}
}
for my $w (2..2) {
for my $x (1..1) {
for my $y (1..4) {
for my $z (1..3) {
$i++;
print "$w $x $y $z\n";
}
}
}
}
print $i ."\n\n";
1
2
3
4
5
6
7
8
9
10
for my $w (2..2) {
for my $x (2..3) {
for my $y (1..4) {
for my $z (1..3) {
$i++;
print "$w $x $y $z\n";
}
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/perl use strict; use warnings; my @clock; for (0..23) { for (0..59) { for (0..59) { push @clock, [$h, $m, $s]; } } }
QuoteUnd wenn Du 7 Teile hast, wie verteilst Du die dann auf 4 CPUs?
Teilst Du dann die 7 Teile nochmal auf Viertel auf?
QuoteAm Ende hat dann eine CPU zur Bestimmung der Aufteilung die Permutationen schon einmal durchrechnen müssen, damit anschließend die Permutationen auf mehreren CPUs berechnetet werden können ;-)
2018-07-18T00:03:16 styx-ccIch habe verschiedene, beliebige Variation, z.B.:
a2 b3 c4 d3 = 72 oder a2 b3 c4 = 24.
Wobei die Zahl die Anzahl der Möglichkeiten pro Stelle angibt und der Buchstabe als Bezeichner der Stelle dient z.B:
a2 = a,b
b3 = a,b,c
c1 = a
d3 = a,b,c
2018-07-18T00:03:16 styx-cca2 = a,b
b3 = a,b,c
c1 = a
d3 = a,b,c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
my $i = 0;
for my $w ('a'..'b') { #als a2 bezeichnet
for my $x ('a'..'c') { #als b3 bezeichnet
for my $y ('a'..'a') { #als c1 bezeichnet
for my $z ('a'..'c') { #als d3 bezeichnet
$i++;
print "$w $x $y $z\n";
}
}
}
}
print $i ."\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
my $ i = 0;
for my $w ('1'..'2') {
for my $x ('1'..'3') {
for my $y ('1'..'1') {
for my $z ('1'..'3') {
$i++;
print "$w $x $y $z\n";
}
}
}
}
print $i ."\n\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
n=4 a2 b3 c1 d3 = 18 (18/n = anzahl pro CPU (4 Rest 2) )
n1) 1-1 1-1 1-1 1-3 = 3
n1) 1-1 2-2 1-1 1-1 = 1
n2) 1-1 2-2 1-1 2-3 = 2
n2) 1-1 3-3 1-1 1-2 = 2
n3) 1-1 3-3 1-1 3-3 = 1
n3 2-2 1-1 1-1 1-3 = 3
n4) 2-2 2-2 1-1 1-3 = 3
n4) 2-2 3-3 1-1 1-1 = 1
RE) 2-2 3-3 1-1 2-3 = 2
1
2
3
4
5
6
n1) von 1 1 1 1 bis 1 2 1 1
n2) von 1 2 1 2 bis 1 3 1 2
n3) von 1 3 1 3 bis 2 1 1 3
n4) von 2 2 1 1 bis 2 3 1 1
RE) von 2 3 1 2 bis 2 3 1 3
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#!/usr/bin/perl use v5.10; use strict; use warnings; use Data::Dumper; my $series = [3, 9, 7, 3, 13, 5, 45]; my $permut = 1; $permut *= $_ for (@$series); my $chunks = 4;#int($permut/100_000_000); $chunks = $chunks < 1 ? 1 : $chunks; my $chunk_size = int($permut / $chunks); my $chunk_start = 1; my $chunk_end = $chunk_size; say join ' ', @$series; say "Permutations: $permut\tChunk size:\t$chunk_size\tChunks:\t$chunks"; my @chunk_ranges; while ($chunk_end <= $permut) { push @chunk_ranges, [ [$chunk_start, cpns($series, $chunk_start)], [$chunk_end, cpns($series, $chunk_end)] ]; $chunk_start += $chunk_size; $chunk_end += $chunk_size; } #last chunk_end contains the rest $permut/$chunk_size gives, #consequential it equals the amount of permutations-1 $chunk_ranges[-1]->[-1] = [$permut, cpns($series, $permut-1)]; print Dumper \@chunk_ranges; sub cpns { convert_positional_notation_systems(@_) }; sub convert_positional_notation_systems { my $bases = shift; my $quotient = shift; my $rest; my @result; for my $base (reverse @$bases) { $rest = $quotient % $base; $quotient = int($quotient / $base); push @result, $rest; last if $quotient == 0; } @result = reverse @result; return join ' ', @result; return \@result; }
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
3 9 7 3 13 5 45
Permutations: 1658475 Chunk size: 414618 Chunks: 4
$VAR1 = [
[
[
1,
'1'
],
[
414618,
'6 5 0 9 3 33'
]
],
[
[
414619,
'6 5 0 9 3 34'
],
[
829236,
'1 4 3 1 6 2 21'
]
],
[
[
829237,
'1 4 3 1 6 2 22'
],
[
1243854,
'2 2 1 2 3 1 9'
]
],
[
[
1243855,
'2 2 1 2 3 1 10'
],
[
1658475,
'2 8 6 2 12 4 44'
]
]
];
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#!/usr/bin/perl use v5.10; use strict; use warnings; use Data::Dumper; my $series = [24, 60, 60]; # h:m:s my $permut = 1; $permut *= $_ for (@$series); my $chunks = 4; $chunks = $chunks < 1 ? 1 : $chunks; my $chunk_size = int($permut / $chunks); my $chunk_start = 0; my $chunk_end = $chunk_size; say join ' ', @$series; say "Permutations: $permut\tChunk size:\t$chunk_size\tChunks:\t$chunks"; my @chunk_ranges; while ($chunk_end <= $permut) { push @chunk_ranges, [ [$chunk_start, cpns($series, $chunk_start)], [$chunk_end-1, cpns($series, $chunk_end-1)] ]; $chunk_start += $chunk_size; $chunk_end += $chunk_size; } #last chunk_end equals amount of permutations-1 $chunk_ranges[-1]->[-1] = [$permut-1, cpns($series, $permut-1)]; print Dumper \@chunk_ranges; sub cpns { convert_positional_notation_systems(@_) }; sub convert_positional_notation_systems { my $bases = shift; my $quotient = shift; my $rest; my @result; for my $base (reverse @$bases) { $rest = $quotient % $base; $quotient = int($quotient / $base); push @result, $rest; last if $quotient == 0; } @result = reverse @result; return join ' ', @result; }