aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Anderson <mark@andemark.io>2025-08-18 09:27:21 +0000
committerMark Anderson <mark@andemark.io>2025-08-18 09:27:21 +0000
commit780da73208c2e7e6d23ccb5fc4ffabb75024085c (patch)
treed747f5d73118fda61b3c0d9a97146170e17ba411
parentb5c0dbb2e29465fb900da10b404beab74b012348 (diff)
downloadperlweeklychallenge-club-780da73208c2e7e6d23ccb5fc4ffabb75024085c.tar.gz
perlweeklychallenge-club-780da73208c2e7e6d23ccb5fc4ffabb75024085c.tar.bz2
perlweeklychallenge-club-780da73208c2e7e6d23ccb5fc4ffabb75024085c.zip
Challenge 335 Solutions (Raku)
-rw-r--r--challenge-335/mark-anderson/raku/ch-2.raku12
1 files changed, 6 insertions, 6 deletions
diff --git a/challenge-335/mark-anderson/raku/ch-2.raku b/challenge-335/mark-anderson/raku/ch-2.raku
index fdc525fa0f..e879873c1c 100644
--- a/challenge-335/mark-anderson/raku/ch-2.raku
+++ b/challenge-335/mark-anderson/raku/ch-2.raku
@@ -1,7 +1,7 @@
#!/usr/bin/env raku
use Test;
-# This solution allows for higher dimensional tic tac toe boards
+# This solution allows for higher dimensional tic-tac-toe boards
# but it doesn't take into account any special rules those may have.
# I didn't check for 'pending' because that's hard to check unless
@@ -17,7 +17,7 @@ sub find-winner(+@moves)
{
my $order = @moves[*;*].max + 1;
- my @board = ('_' xx $order).Array xx $order;
+ my @board = (0 xx $order).Array xx $order;
my $ltr = @moves.end %% 2 ?? 'A' !! 'B';
my $seq := @moves.end %% 2 ?? (0,2...*) !! (1,3...*);
@@ -27,18 +27,18 @@ sub find-winner(+@moves)
return $ltr if any
(
# check rows
- @board.first({ .all eq $ltr }),
+ @board.first.all,
# check upper left to lower right diagonal
((^Inf) Z (^Inf).head(@board))
- .map({ @board[.[0];.[1]] }).all eq $ltr,
+ .map({ @board[.[0];.[1]] }).all,
# check upper right to lower left diagonal
((^Inf) Z (@board.end...0))
- .map({ @board[.[0];.[1]] }).all eq $ltr,
+ .map({ @board[.[0];.[1]] }).all,
# check columns
- ([Z] @board).first({ .all eq $ltr })
+ ([Z] @board).first.all
);
return 'Draw'