From 1bfffd7dd74a4c9e96dde778ad07187e4128e56d Mon Sep 17 00:00:00 2001 From: drbaggy Date: Mon, 7 Jun 2021 21:12:31 +0100 Subject: added in optimization --- challenge-116/james-smith/perl/ch-1.pl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'challenge-116') diff --git a/challenge-116/james-smith/perl/ch-1.pl b/challenge-116/james-smith/perl/ch-1.pl index ffc9471780..43d9d42427 100644 --- a/challenge-116/james-smith/perl/ch-1.pl +++ b/challenge-116/james-smith/perl/ch-1.pl @@ -37,8 +37,7 @@ cmpthese( 200, { sub splitnum { my( $in, $start ) = ( shift, '' ); - #for( split //, substr $in, 0, (length $in) >> 1) { - for( split //, $in ) { + for( split //, substr $in, 0, (length $in) >> 1) { ## $start contains the first number of sequence ## each time through the loop we will add the ## next digit eg 1, 12, 123 @@ -72,10 +71,10 @@ sub splitnum { ## length of $n - but only really valid if you are getting very large ## values of $n...} -## Below is the code above with the commends removed +## Below is the code above with the comments removed sub splitnum_no_comments { my( $in, $st ) = ( shift, '' ); - for( split //, substr $in, 0, ( length $in) >> 1) { + for( split //, substr $in, 0, (length $in) >> 1) { my @r = ( my $t = my $en = $st .= $_ ); ($t .= ++$en) && push @r,$en while $in gt $t && length $in > length $t; -- cgit