aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-048/markus-holzer/raku/ch-1.p610
1 files changed, 8 insertions, 2 deletions
diff --git a/challenge-048/markus-holzer/raku/ch-1.p6 b/challenge-048/markus-holzer/raku/ch-1.p6
index 27637602ca..aeea4eb7e2 100644
--- a/challenge-048/markus-holzer/raku/ch-1.p6
+++ b/challenge-048/markus-holzer/raku/ch-1.p6
@@ -1,9 +1,15 @@
-my @circle = (1..500);
+# perfect example of overcomplicated thinking
+# the shift two, push one method is probably nicer,
+# if not faster
+
+my @circle = 1..500;
+my $offset = 0;
while @circle.elems > 1
{
- my $offset = @circle.elems %% 2 ?? 0 !! 1;
+ my $pivot-man = @circle[ *-2 ];
@circle = @circle[ $offset, { $_ + 2 } ... * ];
+ $offset = @circle[ *-1 ] == $pivot-man ?? 0 !! 1;
}
# Survivor: No. 245