0: #!/usr/bin/perl -w
1: use strict;
2:
3: # Lately everyone's been caught up in Powerball fever
4: # (the jackpot is ~$280 million at time of writing),
5: # so people around my office were starting to play, and
6: # I wrote this to analyze the winning numbers history
7: # text file that powerball.com offers.
8:
9: # (I promise that if I win, I'll donate heavily! :)
10:
11: my ( %numbers, %powerballs, %powerplays );
12:
13: while ( <> ) {
14: next if /^!.*$/;
15: next if /^\s+$/;
16: chomp( my @data = split / / );
17: my $date = shift @data;
18: $powerplays{pop @data}++ if ( $#data == 6 );
19: $powerballs{pop @data}++;
20: $numbers{$_}++ foreach @data;
21: }
22:
23: open OUT, ">powerball.txt" or die "Can't open output file: $!";
24:
25: print OUT <<REGULAR;
26: Regular Numbers:
27: Num\tCount
28: ---\t-----
29: REGULAR
30:
31: foreach ( sort { $numbers{$b} <=> $numbers{$a} } keys %numbers ) {
32: print OUT $_, "\t", $numbers{$_}, "\n";
33: }
34:
35: for ( 1..49 ) {
36: print unless ( $numbers{ sprintf( "%02u", $_ ) } );
37: }
38:
39: print OUT <<POWERBALL;
40:
41: Powerball Numbers:
42: Num\tCount
43: ---\t-----
44: POWERBALL
45:
46: foreach ( sort { $powerballs{$b} <=> $powerballs{$a} } keys %powerballs ) {
47: print OUT $_, "\t", $powerballs{$_}, "\n";
48: }
49:
50: for ( 1..42 ) {
51: print unless ( $powerballs{ sprintf( "%02u", $_ ) } );
52: }
53:
54: print OUT <<POWERPLAY;
55:
56: Powerplay Numbers:
57: Num\tCount
58: ---\t-----
59: POWERPLAY
60:
61: foreach ( sort { $powerplays{$b} <=> $powerplays{$a} } keys %powerplays ) {
62: print OUT $_, "\t", $powerplays{$_}, "\n";
63: }
64:
65: close OUT;
In reply to Powerball mania! by patgas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |