aboutsummaryrefslogtreecommitdiff
path: root/challenge-080
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2020-10-03 17:12:18 +0200
committerAbigail <abigail@abigail.be>2020-10-03 17:12:18 +0200
commitb5f096e5c98876e864bd849814a2c1f3e53d04aa (patch)
treea3ecaefdc006509f3af796857811f5466edfa692 /challenge-080
parentbcfbb8da7e0070de6b6dc53ec6f040a966a759d5 (diff)
downloadperlweeklychallenge-club-b5f096e5c98876e864bd849814a2c1f3e53d04aa.tar.gz
perlweeklychallenge-club-b5f096e5c98876e864bd849814a2c1f3e53d04aa.tar.bz2
perlweeklychallenge-club-b5f096e5c98876e864bd849814a2c1f3e53d04aa.zip
Perl solution for week 80/challenge 1.
Diffstat (limited to 'challenge-080')
-rw-r--r--challenge-080/abigail/perl/ch-1.pl38
1 files changed, 38 insertions, 0 deletions
diff --git a/challenge-080/abigail/perl/ch-1.pl b/challenge-080/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..2bb4050970
--- /dev/null
+++ b/challenge-080/abigail/perl/ch-1.pl
@@ -0,0 +1,38 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+
+#
+# Challenge 1:
+#
+# You are given unsorted list of integers @N.
+#
+# Write a script to find out the smallest positive number missing.
+#
+
+while (<>) {
+ #
+ # Read a line of input, extract the integers, and store
+ # them in a hash %N.
+ #
+ my %N;
+ @N {/-?[0-9]+/g} = ();
+
+ #
+ # Find the missing number: start with 1, increament as long
+ # as it's in %N. We'll stop as soon as we find the missing number.
+ #
+ my $try = 1;
+ $try ++ while exists $N {$try};
+ say $try;
+}
+
+__END__