AoC 2022, day 5

Run Settings
LanguageRaku
Language Version
Run Command
my ($stacks, $actions) = $*IN.slurp.split("\n\n"); my @stacks = $stacks.lines; my \width = @stacks.pop.comb(/\d+/).elems; my @S1 = [] xx (width + 1); for @stacks».comb -> @L { my @a = @L[1, 5 ... width * 4 - 1]; for ^width -> \j { @S1[j+1].push(@a[j]) unless @a[j] eq ' '; } } my @S2 = @S1.deepmap(*.clone); for $actions.lines».comb(/\d+/)».Int -> (\quantity, \from, \to) { @S1[to].unshift(@S1[from].shift) for ^quantity; @S2[to].unshift(|@S2[from].splice(0, quantity)); } put 'part 1: ', @S1[1..width;0].join; put 'part 2: ', @S2[1..width;0].join;
Editor Settings
Theme
Key bindings
Full width
Lines