Last active
August 29, 2015 14:25
-
-
Save tudorconstantin/57e98a4882f8e1cd6e97 to your computer and use it in GitHub Desktop.
loto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Data::Dumper; | |
my $numbers = []; | |
#repetam PANA CAND (de unde si while) avem 6 elemente in $numbers | |
while (scalar @$numbers < 6){ | |
my $extracted_number = int (1 + rand(8)); | |
my @extracted_number_seen = grep { $extracted_number == $_ } @$numbers; | |
#desi @extracted_number_seen e lista, va avea cel mult un element in ea. | |
if (scalar @extracted_number_seen){ | |
#inseamna ca numarul a mai fost extras o data, nu facem nimic aici...cel mult un print de debug | |
print "numbers already extracted @extracted_number_seen\n"; | |
} else { | |
#nemaifiind extras numarul, il luam de bun si-l folosim | |
push @$numbers, $extracted_number; | |
} | |
} | |
print "Numbers: ".Dumper($numbers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment