aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Russell <ac.russell@live.com>2023-12-12 20:42:10 -0500
committerAdam Russell <ac.russell@live.com>2023-12-12 20:42:10 -0500
commite292b631e646b149bd7ecf5739f4325d15db7111 (patch)
tree40bd8ba68550414ed3cc7f3f53cd12a78e0c5ec8
parent75dfef10b6f5580cf581d824ff046c2afa87b159 (diff)
downloadperlweeklychallenge-club-e292b631e646b149bd7ecf5739f4325d15db7111.tar.gz
perlweeklychallenge-club-e292b631e646b149bd7ecf5739f4325d15db7111.tar.bz2
perlweeklychallenge-club-e292b631e646b149bd7ecf5739f4325d15db7111.zip
solution for 246.1 in Perl
-rw-r--r--challenge-246/adam-russell/perl/ch-1.pl22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-246/adam-russell/perl/ch-1.pl b/challenge-246/adam-russell/perl/ch-1.pl
new file mode 100644
index 0000000000..b462c6e959
--- /dev/null
+++ b/challenge-246/adam-russell/perl/ch-1.pl
@@ -0,0 +1,22 @@
+use v5.38;
+##
+# 6 out of 49 is a German lottery.
+# Write a script that outputs six unique random integers from the range 1 to 49.
+##
+package SixOfFourtyNine{
+ use Math::Random::Secure q/irand/;
+ sub pick_six{
+ my @six;
+ {
+ my $r = irand(49) + 1;
+ push @six, $r if 0 == grep {$_ == $r} @six;
+ redo unless @six == 6;
+ }
+ return sort {$a <=> $b} @six;
+ }
+
+}
+
+package main{
+ say join q/, /, SixOfFourtyNine::pick_six;
+}