aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-01-31 15:55:29 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-01-31 15:55:29 +0000
commit8d6c078769dd107a6c8e04142d1b3d83f03c207e (patch)
treeac19dcaf7b12809a33a14cd8057a0427db76549e
parentebcd59a50056e1da3a3f28c98e867c2344548ac6 (diff)
downloadperlweeklychallenge-club-8d6c078769dd107a6c8e04142d1b3d83f03c207e.tar.gz
perlweeklychallenge-club-8d6c078769dd107a6c8e04142d1b3d83f03c207e.tar.bz2
perlweeklychallenge-club-8d6c078769dd107a6c8e04142d1b3d83f03c207e.zip
soln 1
-rw-r--r--challenge-150/james-smith/perl/ch-1.pl27
-rw-r--r--challenge-150/james-smith/perl/ch-2.pl22
2 files changed, 49 insertions, 0 deletions
diff --git a/challenge-150/james-smith/perl/ch-1.pl b/challenge-150/james-smith/perl/ch-1.pl
new file mode 100644
index 0000000000..b7e5227c20
--- /dev/null
+++ b/challenge-150/james-smith/perl/ch-1.pl
@@ -0,0 +1,27 @@
+#!/usr/local/bin/perl
+
+use strict;
+
+use warnings;
+use feature qw(say);
+use Test::More;
+use Benchmark qw(cmpthese timethis);
+use Data::Dumper qw(Dumper);
+
+my @TESTS = (
+ [ [1234,5678], 7 ],
+ [ [5678,1234], 3 ],
+);
+is( fibnum(@{$_->[0]}), $_->[1] ) foreach @TESTS;
+
+done_testing();
+
+sub fibnum_messy {
+ for( my($r,$s) = @_; 51>length $s || return substr $s,50,1;($r,$s) = ($s,$r.$s) ){}
+}
+
+sub fibnum {
+ my ($r,$s) = @_;
+ ($r,$s) = ($s,$r.$s) while 51>length $s;
+ substr $s,50,1;
+}
diff --git a/challenge-150/james-smith/perl/ch-2.pl b/challenge-150/james-smith/perl/ch-2.pl
new file mode 100644
index 0000000000..2348c8b946
--- /dev/null
+++ b/challenge-150/james-smith/perl/ch-2.pl
@@ -0,0 +1,22 @@
+#!/usr/local/bin/perl
+
+use strict;
+
+use warnings;
+use feature qw(say);
+use Test::More;
+use Benchmark qw(cmpthese timethis);
+use Data::Dumper qw(Dumper);
+
+my @TESTS = (
+ [ 0, 1 ],
+);
+
+is( my_function($_->[0]), $_->[1] ) foreach @TESTS;
+
+done_testing();
+
+sub my_function {
+ return 1;
+}
+