-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbracket-score.cgi
executable file
·46 lines (41 loc) · 1.14 KB
/
bracket-score.cgi
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
#!/usr/bin/perl
use FindBin 1.51 qw( $RealBin );
use lib $RealBin;
require 'bracket.pl';
use CGI qw/:standard/;
$q = new CGI;
print "Content-type: text/plain\n\n";
my $tourney = $q->param('t') || "2024m";
setup("$tourney/teams");
my @actual = @{(read_winners("$tourney/actual"))[0]};
my @loser = get_losers(@actual);
my @predicted = find_winners($q->param('c'));
%out = teams_out(@actual);
$score = 0;
for ($i=63; $i>=1; $i--) {
my $r = 6 - int(log2($i));
$max += $score_factor[$r-1];
if (defined $actual[$i]) {
$right = ($actual[$i] == $predicted[$i]);
# print "game $i (r=$r): right=$right\n";
if ($right) {
$score += $score_factor[$r-1];
}
elsif ($loser[$i] == $predicted[$i]) {
print "game $i (round $r) was wrong: $team{$actual[$i]} beat $team{$predicted[$i]}\n";
}
else {
print "game $i (round $r) was wrong: $team{$predicted[$i]} didn't even play\n";
}
}
else {
if ($out{$predicted[$i]}) {
print "game $i (round $r) will be wrong: $team{$predicted[$i]} is already out\n";
}
else {
$possible += $score_factor[$r-1];
}
}
}
$possible += $score;
print "Score: $score / $max Best possible: $possible / $max\n";