use lib $*PROGRAM.parent.parent; use Lib; sub safe($report) { my $diff = $report.rotor(2=>-1).map({ $_[1] - $_[0] }).List; so (1 <= $diff.all <= 3 or -3 <= $diff.all <= -1) } grammar Solution does AOC { token TOP { (^^ \n)+ { make $/[0]>>>>.made; } } token report { ( \h*)+ { make $/[0]>>>>.made;} } token num { \d+ { make val($/.Str) } } method part1(::?CLASS:U: $v) { $v.map(&safe).Bag{True}; } method part2(::?CLASS:U: $v) { $v.map({so safe(.combinations(.elems - 1).any)}).Bag{True} } } Solution.main()