From 8d6c078769dd107a6c8e04142d1b3d83f03c207e Mon Sep 17 00:00:00 2001 From: drbaggy Date: Mon, 31 Jan 2022 15:55:29 +0000 Subject: soln 1 --- challenge-150/james-smith/perl/ch-1.pl | 27 +++++++++++++++++++++++++++ challenge-150/james-smith/perl/ch-2.pl | 22 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 challenge-150/james-smith/perl/ch-1.pl create mode 100644 challenge-150/james-smith/perl/ch-2.pl 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; +} + -- cgit