or nice map/grep exercise...
#!/usr/bin/perl
use strict;
use warnings;
my $draw = [ qw( 13 15 18 22 41 48 ) ];
my $bets = [
[ qw( 09 13 18 33 39 42 ) ],
[ qw( 02 18 32 36 39 42 ) ],
[ qw( 05 12 21 22 28 42 ) ],
[ qw( 03 14 18 33 34 36 ) ],
[ qw( 15 22 26 41 38 48 ) ],
[ qw( 06 14 24 26 42 48 ) ],
[ qw( 10 28 30 35 36 43 ) ],
[ qw( 03 05 08 14 16 35 ) ],
[ qw( 08 18 21 35 46 47 ) ],
[ qw( 03 15 22 25 46 48 ) ],
[ qw( 01 11 38 44 45 49 ) ],
[ qw( 14 23 38 39 48 49 ) ],
[ qw( 07 17 21 32 45 48 ) ],
[ qw( 07 36 37 39 40 41 ) ],
[ qw( 07 12 20 29 36 43 ) ]
];
map {
my $bet = $_;
my $hits = 0;
map {
my $one = $_;
$hits += grep { $one eq $_ } @$bet;
} @$draw;
print join $", @$bet, "-->", $hits, $hits > 2 ? "*" : "", "\n";
} @$bets;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.