AoC 2023, day 11

Run Settings
LanguageRaku
Language Version
Run Command
unit sub MAIN( Str:D $f where *.IO.e = 'input.txt', UInt:D $ex = 1_000_000 ); sub solve($f, $ex) { my @universe is Array = $f.IO.lines.map(*.comb.Array); my @galaxies = (^+@universe X ^+@universe[0]).map({ .Array if @universe[.[0];.[1]] eq '#' }); my @empty-rows = (^+@universe).grep({ $_ != @galaxies.map(*[0]).any }); my @empty-cols = (^+@universe[0]).grep({ $_ != @galaxies.map(*[1]).any }); @galaxies .map({ [ .[0] + $ex * +@empty-rows.grep(* < .[0]), .[1] + $ex * +@empty-cols.grep(* < .[1]) ] }) .combinations(2) .map({ abs(.[0;0] - .[1;0]) + abs(.[0;1] - .[1;1]) }) .sum } put 'part 1: ', solve($f, 1); put 'part 2: ', solve($f, $ex - 1);
Editor Settings
Theme
Key bindings
Full width
Lines