Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
    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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found