diff options
| -rw-r--r-- | challenge-048/mark-anderson/raku/ch-1.p6 | 21 | ||||
| -rw-r--r-- | challenge-048/mark-anderson/raku/ch-2.p6 | 5 |
2 files changed, 15 insertions, 11 deletions
diff --git a/challenge-048/mark-anderson/raku/ch-1.p6 b/challenge-048/mark-anderson/raku/ch-1.p6 index 02fc01baa4..db59eb4ba9 100644 --- a/challenge-048/mark-anderson/raku/ch-1.p6 +++ b/challenge-048/mark-anderson/raku/ch-1.p6 @@ -1,16 +1,15 @@ #!/usr/bin/env perl6 -my @living = 1 .. 50; -my @temp; +# I wish I would have thought of the "push @a, shift @a; shift @a;" solution. -while (@living > 1) { - loop (my $i = 0; $i < @living; $i += 2) { - push @temp, @living[$i]; - } - - shift @temp if @temp[*-1] == @living[*-1]; - @living = @temp; - @temp = []; +my @people = 1 .. 50; + +while @people > 1 { + my $last = @people[*-1]; + + @people = @people[@people.keys.grep(* %% 2)]; + + shift @people if @people[*-1] == $last; } -say @living.pop; +put @people; diff --git a/challenge-048/mark-anderson/raku/ch-2.p6 b/challenge-048/mark-anderson/raku/ch-2.p6 index d5cf44be9c..de498ab3c5 100644 --- a/challenge-048/mark-anderson/raku/ch-2.p6 +++ b/challenge-048/mark-anderson/raku/ch-2.p6 @@ -1,5 +1,7 @@ #!/usr/bin/env perl6 +# Just brute force. + my $mdy = sub ($self) { sprintf "%02d%02d%04d", .month, .day, .year given $self; } @@ -18,5 +20,8 @@ while ($dt.year < 3000) { printf "%02d/%02d/%04d\n", .month, .day, .year given $dt; } + #$dt += 1; # Formatting may be lost with this line + # so I'm doing the below hack for now. + # (The issue has been fixed in Rakudo Star RC-1) $dt = $dt.succ.clone(formatter => $mdy); } |
