Thread Zufalls-LOTTO-Zahlen (9 answers)
Opened by pax77 at 2008-01-29 19:55

topeg
 2008-01-31 00:31
#105369 #105369
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Mit der richtigen Wahl des Algorithmus wird das ganze auch ohne zusätzliche Module sehr klein:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl

use strict;
use warnings;

my @faf=(1,22);

my @z=(1..49);
for my $pos (sort{$b<=>$a}@faf)
{ splice(@z,($pos-1),1); }

for my $cnt (1..12)
{
 my @lotto=@z;
 splice(@lotto,int(rand($#lotto)+0.5),1) while(@lotto > (6-@faf) );
 @lotto=sort{$a<=>$b}(@faf,@lotto);
 printf("Ziehung: %2d -> %s\n", $cnt, join(',',@lotto));
}

View full thread Zufalls-LOTTO-Zahlen