aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-246/bob-lied/perl/ch-1.pl10
1 files changed, 9 insertions, 1 deletions
diff --git a/challenge-246/bob-lied/perl/ch-1.pl b/challenge-246/bob-lied/perl/ch-1.pl
index 394f4db426..56b1ae4e26 100644
--- a/challenge-246/bob-lied/perl/ch-1.pl
+++ b/challenge-246/bob-lied/perl/ch-1.pl
@@ -10,4 +10,12 @@
#=============================================================================
use feature qw/say/;
-say for sort { $a <=> $b} map { int(rand(49)) + 1 } 1..6;
+
+# 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;