aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-06-07 10:57:06 +0100
committerdrbaggy <js5@sanger.ac.uk>2021-06-07 10:57:06 +0100
commitd947cc6a0a440d4e1dae73b3747d9ee02b44d9b1 (patch)
treeef7fe32f836463aeef2777b76e0f6803701e2486
parentda6a2fd160477b502aff0de832ec15f6815fb522 (diff)
downloadperlweeklychallenge-club-d947cc6a0a440d4e1dae73b3747d9ee02b44d9b1.tar.gz
perlweeklychallenge-club-d947cc6a0a440d4e1dae73b3747d9ee02b44d9b1.tar.bz2
perlweeklychallenge-club-d947cc6a0a440d4e1dae73b3747d9ee02b44d9b1.zip
tidied up comments
-rw-r--r--challenge-116/james-smith/perl/ch-1.pl13
1 files changed, 9 insertions, 4 deletions
diff --git a/challenge-116/james-smith/perl/ch-1.pl b/challenge-116/james-smith/perl/ch-1.pl
index be01551f47..1bbc1bd3a4 100644
--- a/challenge-116/james-smith/perl/ch-1.pl
+++ b/challenge-116/james-smith/perl/ch-1.pl
@@ -16,6 +16,7 @@ my @tests = (
);
is( join(',',@{splitnum($_->[0])}),$_->[1] ) foreach @tests;
+is( join(',',@{splitnum_no_comments($_->[0])}),$_->[1] ) foreach @tests;
done_testing();
@@ -34,7 +35,8 @@ sub splitnum {
## We concatenate the of "end" onto $string until
## it is equal to or larger than the input number
- $string .= ++$end while $in gt $string && length $in > length $string;
+ $string .= ++$end while $in gt $string
+ && length $in > length $string;
## Finally we return the list if the input and
## string are the same. Note we will always get
@@ -54,12 +56,15 @@ 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
sub splitnum_no_comments {
- my($in,$st) = (shift,'');
+ my( $in, $st ) = ( shift, '' );
for( split //, $in ) {
my $t = my $en = $st .= $_;
- $t .= ++$en while $in gt $t && length $in > length $t;
- return [$st..$en] if $t eq $in;
+ $t .= ++$en while $in gt $t
+ && length $in > length $t;
+ return [ $st .. $en ] if $t eq $in;
}
}