Avoid numbers that others commonly use.

This commit is contained in:
Bradley M. Kuhn 2022-11-09 11:14:47 -08:00
parent ec22febde3
commit 0237e90fd6

View file

@ -26,13 +26,23 @@ while ($curTix < $tixCount) {
my $rr; my $rr;
while (read($randomFH, $rr, 4) != 4) { } while (read($randomFH, $rr, 4) != 4) { }
$rr = unpack("I", $rr) % scalar(@choices); $rr = unpack("I", $rr) % scalar(@choices);
$rr = $choices[$rr];
if (scalar(keys(%done)) < @choices) { if (scalar(keys(%done)) < @choices) {
next if defined $done{$rr}; next if defined $done{$rr};
$done{$rr} = 1; $done{$rr} = 1;
} else { } else {
next if $rr < 31;
my %inThisTicket = map { $_, 1 } @{$tix[$curTix]}; next if $inThisTicket{$rr}; my %inThisTicket = map { $_, 1 } @{$tix[$curTix]}; next if $inThisTicket{$rr};
my $min = min(grep { $_ > 31} values %done); next if $done{$rr} > $min;
my $hundred;
while (read($randomFH, $hundred, 4) != 4) { }
$hundred = unpack("I", $hundred) % 100;
next if ($rr <= 31) and ($hundred > 40);
next if ($rr == 7) and ($hundred > 5);
my $min = min(@done{grep { $_ > 31} keys %done});
next if $done{$rr} > $min;
$done{$rr}++;
} }
push(@{$tix[$curTix]}, $rr); push(@{$tix[$curTix]}, $rr);
} }
@ -40,5 +50,11 @@ while ($curTix < $tixCount) {
} }
my $count = 1; my $count = 1;
foreach my $ticket (@tix) { foreach my $ticket (@tix) {
print "Ticket $count: ", join(" ", sort { $a <=> $b } @$ticket), "\n"; print sprintf("Ticket %2d: ", $count), map { sprintf("%2d ", $_) } sort { $a <=> $b } @$ticket;
print "\n";
$count++;
} }
#print "\n\nStats\n";
#foreach my $choice (sort { $a <=> $b } keys %done) {
# print sprintf("%2d used: %2d\n", $choice, $done{$choice});
# }