aboutsummaryrefslogtreecommitdiff
path: root/challenge-246/bob-lied/perl/ch-1.pl
blob: 56b1ae4e26f17517a8fe036af00e71eee9c64fdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl
# vim:set ts=4 sw=4 sts=4 et ai wm=0 nu:
#=============================================================================
# ch-1.pl Perl Weekly Challenge 246 Task 1 6 out of 49
#=============================================================================
# Copyright (c) 2023, Bob Lied
#=============================================================================
# 6 out of 49 is a German lottery.
# Write a script that outputs six unique random integers from the range 1 to 49.
#=============================================================================

use feature qw/say/;

# Choose six numbers without repeats
my %seen;
while ( scalar(keys %seen) < 6 )
{
    $seen{ int(rand(49)) + 1 } = 1;
}

say for sort { $a <=> $b } keys %seen;