# usage: raku day3.raku [path/to/input] (default: ../data/day3.txt) my $path = @*ARGS[0] // '../data/day3.txt'; my @grid = $path.IO.lines.map(*.comb.Array); my ($h, $w) = (@grid.elems, @grid[0].elems); my $count = 0; for 0 ..^ $h -> $r { for 0 ..^ $w -> $c { next unless @grid[$r][$c] eq '#'; for 1 .. min($h - $r, $w - $c) - 1 -> $s { $count++ if @grid[$r][$c + $s] eq '#' && @grid[$r + $s][$c] eq '#' && @grid[$r + $s][$c + $s] eq '#'; } } } say $count;