aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-101/james-smith/perl/ch-1.pl6
1 files changed, 2 insertions, 4 deletions
diff --git a/challenge-101/james-smith/perl/ch-1.pl b/challenge-101/james-smith/perl/ch-1.pl
index 18434b2b69..b223880b14 100644
--- a/challenge-101/james-smith/perl/ch-1.pl
+++ b/challenge-101/james-smith/perl/ch-1.pl
@@ -15,16 +15,14 @@ sub print_spiral {
}
sub pack_spiral {
- my $rows = 1;
## Get the value for columns & rows which have the smallest gap
## but still multiply to size of array (we choose rows to be
## no greater than columns as printing is neater - but for no
## other reason...
- $rows = @_%$_ ? $rows : $_ foreach 2 .. sqrt @_;
-
- my ($cols,$r,$c,@out) = (@_/$rows,$rows-1,-1);
+ my( $rows ) = reverse grep { ! (@_ % $_) } 1 .. sqrt @_;
+ my( $cols, $r, $c, @out ) = ( @_/$rows, $rows-1, -1 );
## We start bottom left...
## because we use pre-inc we actually start 1 to the left of it!