Texas Lotto Numbers

Posted by Michael Palmer on Wednesday, July 30, 2003

Ok, so the Texas Lotto is up to $47 million. So I decided, screw these quick pic machines, ill just write a Perl script to give you random numbers. It works great. Gonna play the numbers tonight.

[ Check it out ]

If you’re interested here’s my code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl -w
use strict;

my $times = $ARGV[0] || 1;

for (1..$times) {
    my @numbers;
    for(1..5) {
        my $num = randm();
        until ("@numbers" !~ /$num/) {
            $num = randm();
        }
        push (@numbers,$num);
    }
    @numbers = sort {$a <=> $b }@numbers;
    print "@numbers ".randm()."BB\n";
}

sub randm {
    sprintf("%2.2d ",int(rand(44))+1);
}

Wog and Metlhed came up with a one liner:

1
sub r{sprintf"%02d",1+rand 44}while($ARGV[0]--){$_=my%n;$n{+r}++,$_="@{[sort+keys%n]}| ".r."-BB\n"until 22==y///c;print}

comments powered by Disqus