aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-246/paulo-custodio/Makefile2
-rw-r--r--challenge-246/paulo-custodio/perl/ch-1.pl36
-rw-r--r--challenge-246/paulo-custodio/t/test-1.yaml11
3 files changed, 49 insertions, 0 deletions
diff --git a/challenge-246/paulo-custodio/Makefile b/challenge-246/paulo-custodio/Makefile
new file mode 100644
index 0000000000..c3c762d746
--- /dev/null
+++ b/challenge-246/paulo-custodio/Makefile
@@ -0,0 +1,2 @@
+all:
+ perl ../../challenge-001/paulo-custodio/test.pl
diff --git a/challenge-246/paulo-custodio/perl/ch-1.pl b/challenge-246/paulo-custodio/perl/ch-1.pl
new file mode 100644
index 0000000000..06ba5ed0b9
--- /dev/null
+++ b/challenge-246/paulo-custodio/perl/ch-1.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl
+
+# Challenge 246
+#
+# Task 1: 6 out of 49
+# Submitted by: Andreas Voegele
+#
+# 6 out of 49 is a German lottery.
+#
+# Write a script that outputs six unique random integers from the range 1 to 49.
+# Output
+#
+# 3
+# 10
+# 11
+# 22
+# 38
+# 49
+
+use Modern::Perl;
+
+use constant NR_BALLS => 49;
+use constant NR_DRAWS => 6;
+
+if (@ARGV) {
+ srand($ARGV[0]+0);
+}
+
+my @balls = (1..NR_BALLS);
+my @drawn;
+for (1..NR_DRAWS) {
+ my $i = int(rand()*scalar(@balls));
+ push @drawn, splice(@balls, $i, 1);
+}
+
+say join("\n", sort {$a<=>$b} @drawn);
diff --git a/challenge-246/paulo-custodio/t/test-1.yaml b/challenge-246/paulo-custodio/t/test-1.yaml
new file mode 100644
index 0000000000..e0f8f2c284
--- /dev/null
+++ b/challenge-246/paulo-custodio/t/test-1.yaml
@@ -0,0 +1,11 @@
+- setup:
+ cleanup:
+ args: 1234
+ input:
+ output: |
+ |11
+ |14
+ |16
+ |17
+ |37
+ |49