summaryrefslogtreecommitdiff
path: root/2024/02/raku.raku
blob: 9b930de38f0f89694237fbf28050411e840ebd97 (plain)
1
2
3
4
5
6
7
8
9
#!/usr/bin/env raku

my @rs = lines>>.words.map(&cache);

sub incr ($r) { $r.rotor(2=>-1).map({ ([-] $_) (elem) (1..3)}).all };
sub safe ($r) { so $r.&incr || $r.reverse.&incr };

say "silver: ", @rs.map(&safe).sum;
say "gold: ", @rs.map({ $_.combinations($_-1).map(&safe).any.so }).sum;