X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=2022%2F10.pl;h=0dcf15f87c1d13ea6350b300118f09517a539408;hb=ec283da1f9eb5574ace9f827dc811be8a6c48e47;hp=913e078d860582ba3385330017e9e296b7ab438d;hpb=992ea7b162b0ce64553e4c10118d12163b13c696;p=aoc.git diff --git a/2022/10.pl b/2022/10.pl index 913e078..0dcf15f 100755 --- a/2022/10.pl +++ b/2022/10.pl @@ -8,14 +8,10 @@ my @stacks; while (<>) { last if /^ \d/; - my $i = 1; - my $st = 0; - $stacks[$st] //= []; - while ($i < length) { - my $c = substr($_, $i, 1); - unshift @{ $stacks[$st] }, $c if $c =~ /[A-Z]/; - $i += 4; - $st++; + my $i = 0; + for (/.(.). ?/g) { + unshift @{ $stacks[$i] }, $_ if /[A-Z]/; + $i++; } }