diff options
| author | Mark A <andemark@a-iot1t.uch.ad.pvt> | 2021-02-28 08:34:25 -0700 |
|---|---|---|
| committer | Mark A <andemark@a-iot1t.uch.ad.pvt> | 2021-02-28 08:34:25 -0700 |
| commit | 231ff472626b734e39de1591acf35ece779e12a1 (patch) | |
| tree | f92602c701266fc3eaeec76403596f17c953a46d /challenge-101 | |
| parent | 826573f083db1ae1a9274934d222bbe416d2b355 (diff) | |
| download | perlweeklychallenge-club-231ff472626b734e39de1591acf35ece779e12a1.tar.gz perlweeklychallenge-club-231ff472626b734e39de1591acf35ece779e12a1.tar.bz2 perlweeklychallenge-club-231ff472626b734e39de1591acf35ece779e12a1.zip | |
minor touch-up to ch-1.raku
Diffstat (limited to 'challenge-101')
| -rw-r--r-- | challenge-101/mark-anderson/raku/ch-1.raku | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/challenge-101/mark-anderson/raku/ch-1.raku b/challenge-101/mark-anderson/raku/ch-1.raku index f75cf266b0..619d66c316 100644 --- a/challenge-101/mark-anderson/raku/ch-1.raku +++ b/challenge-101/mark-anderson/raku/ch-1.raku @@ -37,12 +37,13 @@ is-deeply pack-a-spiral(1..144), ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) ); +# +# not exactly the most efficient solution... +# sub pack-a-spiral(@list is copy) { - my $factor = .tail given map { +@list div $_ if @list %% $_ }, - 1..sqrt(@list); - - my @matrix = @list.keys.rotor($factor).map(*.Array); + my $cols = +@list div (1..sqrt(@list).floor).first(@list %% *, :end); + my @matrix = @list.keys.rotor($cols).map(*.Array); my @keys; while @matrix @@ -54,5 +55,5 @@ sub pack-a-spiral(@list is copy) } @list[@keys] = @list; - @list.rotor($factor); + @list.rotor($cols); } |
