-
Notifications
You must be signed in to change notification settings - Fork 1
/
balance-sched.pl
executable file
·65 lines (55 loc) · 1.67 KB
/
balance-sched.pl
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
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w
use strict;
my %sched;
# Not balanced...
%sched = (
0 => [ "", "", "", "", "", "" ],
1 => [ "3-1", "6-2", "5-4", "", "", "1" ],
2 => [ "1-6", "4-3", "2-5", "", "", "1" ],
3 => [ "2-1", "6-4", "5-3", "", "", "4" ],
4 => [ "3-2", "6-5", "4-1", "", "", "4" ],
5 => [ "4-2", "3-6", "1-5", "", "", "5" ],
6 => [ "1-3", "2-6", "4-5", "", "", "5" ],
7 => [ "6-1", "3-4", "5-2", "", "", "6" ],
8 => [ "1-2", "4-6", "3-5", "", "", "6" ],
9 => [ "2-3", "5-6", "1-4", "", "", "2" ],
10 => [ "2-4", "6-3", "5-1", "", "", "2" ],
);
# My by hand attempt...
%sched = (
0 => [ "3-2", "4-6", "1-5", "", "", "3" ],
1 => [ "2-1", "3-6", "4-5", "", "", "1" ],
2 => [ "3-4", "2-5", "6-1", "", "", "3" ],
3 => [ "6-4", "1-5", "2-3", "", "", "4" ],
4 => [ "4-1", "6-2", "5-3", "", "", "4" ],
5 => [ "5-6", "1-3", "4-2", "", "", "5" ],
6 => [ "5-4", "1-2", "6-3", "", "", "5" ],
7 => [ "5-2", "4-3", "1-6", "", "", "6" ],
8 => [ "5-1", "6-4", "3-2", "", "", "6" ],
9 => [ "2-6", "3-5", "1-4", "", "", "2" ],
10 => [ "3-1", "2-4", "6-5", "", "", "2" ],
);
my %sum;
foreach my $w (sort { $a <=> $b} keys %sched) {
print "Week: $w\t";
my @m = @{$sched{$w}};
my $c=1;
foreach (@m) {
if (m/\d+\-\d+/) {
print "$_\t";
my ($h,$a) = split("-",$_);
$sum{$h}{$c}++;
$sum{$a}{$c}++;
$c++;
}
}
print "\n";
}
print "--------------\n";
foreach my $t (sort keys %sum) {
print "Team: $t\t ";
foreach my $p (sort keys %{$sum{$t}}) {
print "$p = $sum{$t}{$p}\t";
}
print "\n";
}