Advent of Code solutions

upgrading scripts more

+8 -7
+1 -1
2022/1/p2.sh
··· 45 45 top3=$temp 46 46 fi 47 47 48 - echo $top1 + $top2 + $top3 = $((top1 + top2 + top3)) 48 + echo $((top1 + top2 + top3))
+1 -3
2022/2/p1.pl
··· 38 38 !. 39 39 40 40 main :- 41 - open("input", read, Fd), 42 - read_stream_to_codes(Fd, Contents), 43 - close(Fd), 41 + read_stream_to_codes(user_input, Contents), 44 42 split_string(Contents, "\n", " ", Lines), 45 43 sum_score(Lines, Score), 46 44 write(Score), write("\n").
+6 -3
Justfile
··· 17 17 [no-cd] 18 18 do part input: 19 19 #!/usr/bin/env fish 20 - if test -f {{part}}.hs 20 + set fn (fd -d 1 -t f {{part}}) 21 + if test -n "$fn" -a -x "$fn" 22 + time ./$fn < {{input}} 23 + else if test -f {{part}}.pl 24 + and time swipl -s "$fn" -g main,halt < {{input}} 25 + else if test -f {{part}}.hs 21 26 ghc {{part}} -O -outputdir.{{part}} > /dev/null 22 27 and time ./{{part}} < {{input}} 23 28 else if ls | rg "\.cabal\$" -q 24 29 cabal build {{part}} > /dev/null 25 30 and time cabal run {{part}} < {{input}} 26 - else if test -f {{part}}.fish 27 - time ./{{part}}.fish < {{input}} 28 31 else 29 32 echo "Current directory does not contain known solution configuration" 30 33 exit 1