Advent of Code solutions

more language support

+17 -2
+4
2022/5/p1.pl
··· 1 + #!/usr/bin/perl 2 + 1 3 @lists = ( 2 4 ["V", "N", "F", "S", "M", "P", "H", "J"], 3 5 ["Q", "D", "J", "M", "L", "R", "S"], ··· 10 12 ["F", "B", "P", "G", "V", "J", "S", "D"], 11 13 ); 12 14 15 + $i = 0; 13 16 while (<>) { 17 + if ($i++ < 10) { next; } 14 18 last unless /\S/; 15 19 /move (\d+) from (\d+) to (\d+)/; 16 20 $n = $1;
+3
2022/5/p2.pl
··· 1 + #!/usr/bin/perl 1 2 @lists = ( 2 3 ["V", "N", "F", "S", "M", "P", "H", "J"], 3 4 ["Q", "D", "J", "M", "L", "R", "S"], ··· 10 11 ["F", "B", "P", "G", "V", "J", "S", "D"], 11 12 ); 12 13 14 + $i = 0; 13 15 while (<>) { 16 + if ($i++ < 10) { next; } 14 17 last unless /\S/; 15 18 /move (\d+) from (\d+) to (\d+)/; 16 19 @top = splice @{$lists[$2 - 1]}, 0, $1;
+10 -2
Justfile
··· 19 19 #!/usr/bin/env fish 20 20 set fn (fd -d 1 -t f {{part}}) 21 21 if test -n "$fn" -a -x "$fn" 22 - time ./$fn < {{input}} 22 + time "./$fn" < {{input}} 23 23 else if test -f {{part}}.pl 24 - and time swipl -s "$fn" -g main,halt < {{input}} 24 + time swipl -s "$fn" -g main,halt < {{input}} 25 + else if test -f {{part}}.py 26 + time python3 "$fn" < {{input}} 27 + else if test -f {{part}}.c 28 + gcc "$fn" -o {{part}} > /dev/null 29 + and time ./{{part}} < {{input}} 30 + else if test -f {{part}}.cpp 31 + g++ -std=c++2c "$fn" -o {{part}} > /dev/null 32 + and time ./{{part}} < {{input}} 25 33 else if test -f {{part}}.hs 26 34 ghc {{part}} -O -outputdir.{{part}} > /dev/null 27 35 and time ./{{part}} < {{input}}