aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-119/lance-wicks/perl/ch-2.pl13
-rw-r--r--challenge-119/lance-wicks/perl/lib/Sequence.pm23
-rw-r--r--challenge-119/lance-wicks/perl/t/02-seq.t7
3 files changed, 43 insertions, 0 deletions
diff --git a/challenge-119/lance-wicks/perl/ch-2.pl b/challenge-119/lance-wicks/perl/ch-2.pl
new file mode 100644
index 0000000000..c8ec9fe6a3
--- /dev/null
+++ b/challenge-119/lance-wicks/perl/ch-2.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+use lib './lib';
+use Sequence;
+my $seq = Sequence->new;
+
+my $n = $ARGV[0];
+my $res = $seq->no_one_on_one($n);
+
+print "Input \$N = $n\n";
+print "Output: $res\n";
+
diff --git a/challenge-119/lance-wicks/perl/lib/Sequence.pm b/challenge-119/lance-wicks/perl/lib/Sequence.pm
new file mode 100644
index 0000000000..a938d06b92
--- /dev/null
+++ b/challenge-119/lance-wicks/perl/lib/Sequence.pm
@@ -0,0 +1,23 @@
+package Sequence;
+
+use Moo;
+
+sub no_one_on_one {
+ my ( $self, $n ) = @_;
+
+ my @seq;
+
+ my $x = 0;
+ while (1) {
+ $x++;
+ next unless $x =~ /^[123]/;
+ next if $x =~ /[4567890]/g;
+ next if $x =~ /11/g;
+ push @seq, $x;
+ last if @seq > $n - 1;
+ }
+ return $seq[-1];
+}
+
+1;
+
diff --git a/challenge-119/lance-wicks/perl/t/02-seq.t b/challenge-119/lance-wicks/perl/t/02-seq.t
new file mode 100644
index 0000000000..86865e8047
--- /dev/null
+++ b/challenge-119/lance-wicks/perl/t/02-seq.t
@@ -0,0 +1,7 @@
+use Test2::V0 -target => Sequence;
+
+is $CLASS->no_one_on_one(5), 13, "Example 1";
+is $CLASS->no_one_on_one(10), 32, "Example 2";
+is $CLASS->no_one_on_one(60), 2223, "Example 3";
+
+done_testing;