aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-09-04 02:28:21 +0200
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-09-04 02:28:21 +0200
commitb85c20f113703b3f09d4ab5d1a4ec57e1d4b9811 (patch)
tree5605aaf91584c25527ac3fe7d943f5b654a13a02
parent68335325d590023de8c049cbbbbea1b62fa83665 (diff)
downloadperlweeklychallenge-club-b85c20f113703b3f09d4ab5d1a4ec57e1d4b9811.tar.gz
perlweeklychallenge-club-b85c20f113703b3f09d4ab5d1a4ec57e1d4b9811.tar.bz2
perlweeklychallenge-club-b85c20f113703b3f09d4ab5d1a4ec57e1d4b9811.zip
comb can take a matcher. d'oh
-rw-r--r--challenge-076/markus-holzer/raku/ch-2.raku7
1 files changed, 3 insertions, 4 deletions
diff --git a/challenge-076/markus-holzer/raku/ch-2.raku b/challenge-076/markus-holzer/raku/ch-2.raku
index 19295ba61d..95bebac892 100644
--- a/challenge-076/markus-holzer/raku/ch-2.raku
+++ b/challenge-076/markus-holzer/raku/ch-2.raku
@@ -1,9 +1,8 @@
unit sub MAIN($words-file, $board-file);
my @words = $words-file.IO.lines;
-my @board = $board-file.IO.slurp.subst( ' ', :g ).lines;
-my $width = @board.head.chars;
-my @chars = @board.map: |*.comb;
+my $width = $board-file.IO.lines.head.chars div 2 + 1;
+my @chars = $board-file.IO.slurp.comb( /\w/ );
.Str.say for words-in rotated-data.flat.join;
@@ -11,7 +10,7 @@ sub words-in( $text ) {
$text ~'~'~ $text.flip ~~ m:ex:i/@words/ }
sub rotated-data {
- @chars.batch( $width ), |( (0,0),(0,1),(1,0) ).map: &rotate-data }
+ @chars.batch( $width ), |( (0,0), (0,1), (1,0) ).map: &rotate-data }
sub rotate-data( @offsets ) {
(^$width).map: { @chars[ ($_ + @offsets[0]), ($_ + $width + @offsets[1]) ... * ] } } \ No newline at end of file