From b85c20f113703b3f09d4ab5d1a4ec57e1d4b9811 Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Fri, 4 Sep 2020 02:28:21 +0200 Subject: comb can take a matcher. d'oh --- challenge-076/markus-holzer/raku/ch-2.raku | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'challenge-076') 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 -- cgit