aboutsummaryrefslogtreecommitdiff
path: root/challenge-116/james-smith/perl
diff options
context:
space:
mode:
authorJames Smith <baggy@baggy.me.uk>2021-06-07 10:48:39 +0100
committerGitHub <noreply@github.com>2021-06-07 10:48:39 +0100
commitd9649d3b3fc16ec18b3d95cb7ffbcd6e56e0deda (patch)
treec6beb89f08e5e5e281963379c4b50002285c8ff4 /challenge-116/james-smith/perl
parentcedb03a9cb9a6b1f3838001a202fec11ba673c65 (diff)
downloadperlweeklychallenge-club-d9649d3b3fc16ec18b3d95cb7ffbcd6e56e0deda.tar.gz
perlweeklychallenge-club-d9649d3b3fc16ec18b3d95cb7ffbcd6e56e0deda.tar.bz2
perlweeklychallenge-club-d9649d3b3fc16ec18b3d95cb7ffbcd6e56e0deda.zip
Update ch-1.pl
Diffstat (limited to 'challenge-116/james-smith/perl')
-rw-r--r--challenge-116/james-smith/perl/ch-1.pl9
1 files changed, 4 insertions, 5 deletions
diff --git a/challenge-116/james-smith/perl/ch-1.pl b/challenge-116/james-smith/perl/ch-1.pl
index a4bc29f7cc..be01551f47 100644
--- a/challenge-116/james-smith/perl/ch-1.pl
+++ b/challenge-116/james-smith/perl/ch-1.pl
@@ -20,8 +20,7 @@ is( join(',',@{splitnum($_->[0])}),$_->[1] ) foreach @tests;
done_testing();
sub splitnum {
- my($in,$start) = (shift,''); ## collect param
- ## initialize number
+ my( $in, $start ) = ( shift, '' );
foreach( split //, $in ) {
## $start contains the first number of sequence
## each time through the loop we will add the
@@ -30,7 +29,7 @@ sub splitnum {
## $end contains a copy of this, which we will
## then incremement as we generate the sum
- my $string = my $end = ($start .= $_ );
+ my $string = my $end = $start .= $_;
## We concatenate the of "end" onto $string until
## it is equal to or larger than the input number
@@ -57,8 +56,8 @@ sub splitnum {
sub splitnum_no_comments {
my($in,$st) = (shift,'');
- foreach( split //, $in ) {
- my $t = my $en = ($st .= $_ );
+ 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;
}