diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-02-23 05:10:43 +0000 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-02-23 05:10:43 +0000 |
| commit | cc69036ae26a587aa9a79156029c90fe67f7069a (patch) | |
| tree | 2e2ae8a54ab4554c020498a642a96796c2b9fe93 /challenge-101 | |
| parent | aa52dd453a66122e8a51ebbbe27222f7c9d47667 (diff) | |
| download | perlweeklychallenge-club-cc69036ae26a587aa9a79156029c90fe67f7069a.tar.gz perlweeklychallenge-club-cc69036ae26a587aa9a79156029c90fe67f7069a.tar.bz2 perlweeklychallenge-club-cc69036ae26a587aa9a79156029c90fe67f7069a.zip | |
tidied up initialiser
Diffstat (limited to 'challenge-101')
| -rw-r--r-- | challenge-101/james-smith/perl/ch-1.pl | 6 |
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! |
