Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

pudge
  (email not shown publicly)
http://pudge.net/
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Monday October 29, 2007
12:39 AM

Sox Win, As Formula Predicted

[ #34776 ]

So in 2004 I predicted the Red Sox would win in 2006, using a mathematical formula. I was wrong. So I realized that my formula was off. Because the length of difference between last year won and the pivotal year of beating St. Louis crossed millennia, we had to add an extra year.

#!/usr/bin/perl
use warnings;
use strict;
 
# script to predict when the next Boston team championship
# will occur after either:
#
# * winning first championship in team history, against St. Louis
#
# OR
#
# * winning first championship since St. Louis existed as a team
 
my %boston_team = (
    # team        last year won,  year beat St. Louis
    Celtics   => [1957,           1957],
    Bruins      => [1941,           1970],
    Patriots  => [2002,           2002],
    'Red Sox' => [1918,           2004],
);
 
for my $team (sort { $boston_team{$a}[1] <=> $boston_team{$b}[1] } keys %boston_team) {
    printf "%s: %d\n", $team,
        predict_year(@{$boston_team{$team}});
 
}
 
sub predict_year {
    my($last_won, $beat_stl) = @_;
    my $base_year = $beat_stl + 2;
    $base_year += int($beat_stl/1000) - int($last_won/1000); # adjust for difference
    return $base_year;
}
 
__END__

This formula correctly "predicts" the next championship of each team:

Celtics: 1959
Bruins: 1972
Patriots: 2004
Red Sox: 2007

I CALLED IT!!!!!</colbert>

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.