I took a look at chromatic's program from 2000. Great code to start from.
I updated the code to process the current www.powerball.com winnums-text.txt file, after you've saved it to disk and stripped the one header line, and deleted draws before 08/31/2005 (the last modification to the game).
Also, my mod'd version of your program -
1) analyzes powerball and white balls separately,
2) determines a list of "cold" low count balls, "mid" middle count balls, and "hot" high count balls, and
3) does not report the Power Pick (or multiplier).
I will continue to tweek it until it is acceptable to me, and I'll probably post it to a new page here on Perl Monks with the same attribution currently in the code when my verison is to the point that it can --
1) use GET to access the current file, and
2) ignore the first header line while processing(will have to change the foreach to a while, I think... I know I've done this before on another Perl project).
Anyway, here's my copy after working for a few mins updating a couple of things and changing the reported numbers slightly ...
My current listing follows (I hope) --
#!/usr/bin/perl -w
# originally from http://www.perlmonks.org/
# Powerball Frequency Analyzer
# by chromatic (Bishop)
# originally based upon old pbhist.txt
# updated to current history
# also run current "winnums-text.txt" format with no header line
# with draws since last rule change in 2005/08/31
#
use strict;
use warnings;
use LWP::Simple;
my (@numbers, %normals, %powerb, %powers);
my $content;
#### bns - updated the link to the draw file
## unless (defined ($content = get('http://www.powerball.com/results/p
+bhist.txt'))) {
## die "Cannot get PB history.\n";
## }
## unless (defined ($content = get('http://www.powerball.com/powerball
+/winnums-text.txt'))) {
## die "Cannot get PB history.\n";
## }
unless (defined ($content = get('file:///J:/DivX/current-game-winnums-
+text.txt'))) {
die "Cannot get PB history.\n";
}
@numbers = split /\n/, $content;
my @data;
foreach my $line (@numbers) {
next if ($line =~ /^!/);
@data = split(/\s/, $line);
shift @data; # throw away the date
$powers{pop @data}++;
pop @data;
$powerb{pop @data}++;
foreach (@data) {
$normals{$_}++;
}
}
print "Normal (White Ball) Pick Rate:\n\n";
my @norm_sort = sort { $normals{$a} <=> $normals{$b} } keys %normals;
foreach (@norm_sort) {
print "$_ :\t($normals{$_})\t", "*" x $normals{$_}, "\n";
}
print "PowerBall Normal Pick Rate:\n\n";
my @pb_sort = sort { $powerb{$a} <=> $powerb{$b} } keys %powerb;
foreach (@pb_sort) {
print "$_ :\t($powerb{$_})\t", "*" x $powerb{$_}, "\n";
}
print "\nPower Pick Rate:\n\n";
my @pp_sort = sort { $powers{$a} <=> $powers{$b} } keys %powers;
foreach (@pp_sort) {
print "$_ :\t($powers{$_})\t", "*" x $powers{$_}, "\n";
}
print "\nWhite Balls --";
print "\n Cold Picks:\t";
print join(" ", @norm_sort[0 .. 4]), "\n";
print " Mid Picks:\t";
print join(" ", @norm_sort[25 .. 29]), "\n";
print " Hot Picks:\t";
print join(" ", @norm_sort[50 .. 54]), "\n";
print "\nPowerBalls --";
print "\n Cold Picks:\t";
print join(" ", sort (@pb_sort[0 .. 2])), "\n";
print " Mid Pick:\t";
print join(" ", sort (@pb_sort[19 .. 21])), "\n";
print " Hot Picks:\t";
print join(" ", sort (@pb_sort[39 .. 41])), "\n";
## print "\nPower Picks:\t";
## print join(" ", sort (@pp_sort[0 .. 3])), "\n";
print "\nDisclaimer:\n\tThis is not statistically accurate, except in
+that the drawings are
guaranteed.\nThis is just a quick frequency analysis making no pretens
+es as to predictive
accuracy.\n";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.