-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck-actual
executable file
·60 lines (53 loc) · 1.4 KB
/
check-actual
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
#!/usr/bin/perl
#
# Check that...
# * the winner of each game was a participant in that game
# * nobody won a game after losing a game (redundant?)
# * every score is N-M, with N > M
use FindBin 1.51 qw( $RealBin );
use lib $RealBin;
require 'bracket.pl';
if (! @ARGV || ! -d $ARGV[0]) {
print STDERR "Usage:\n $0 yyyyt\n\nE.g., $0 2024m\n";
exit 1;
}
my $tourney = $ARGV[0];
setup("$tourney/teams");
my @refs = read_winners("$tourney/actual");
my @actual = @{$refs[0]};
my @score_winner = @{$refs[1]};
my @score_loser = @{$refs[2]};
my %out = teams_out(@actual);
$errors = 0;
for ($i=63; $i>=1; $i--) {
my ($a, $b);
if ($i >= 32) {
($a, $b) = split/,/, $game{$i};
}
else {
($a, $b) = @actual[$i*2, $i*2+1];
}
if (defined $actual[$i] && $actual[$i] != $a && $actual[$i] != $b) {
print "$team{$actual[$i]} ($actual[$i]) didn't play in game $i\n";
$errors++;
}
}
foreach (1..63) {
if (defined $actual[$_] && $out{$actual[$_]}
&& 2**(7-$out{$actual[$_]}) > $_) {
print "$team{$actual[$_]} ($actual[$_]) out in round $out{$actual[$_]} but winning game $_.\n";
$errors++;
}
}
foreach $i (1..63) {
next if !(defined $score_winner[$i] || defined $score_loser[$i]);
if ($score_winner[$i] < $score_loser[$i]) {
print "Game $i: winner score comes first\n";
$errors++;
}
if ($score_winner[$i] == $score_loser[$i]) {
print "Game $i: a tie?\n";
$errors++;
}
}
print "No errors\n" if $errors == 0;