Advent of Code solutions

try more trilogy solutions to see how it goes

+41 -2
+10 -1
2023/1/p1.tri
··· 3 3 import "trilogy:array" use filter, map, fold, collect 4 4 import "trilogy:parsec" use parse, integer 5 5 6 - func is_digit '0' or '1' or '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' = true 6 + func is_digit '0' = true 7 + func is_digit '1' = true 8 + func is_digit '2' = true 9 + func is_digit '3' = true 10 + func is_digit '4' = true 11 + func is_digit '5' = true 12 + func is_digit '6' = true 13 + func is_digit '7' = true 14 + func is_digit '8' = true 15 + func is_digit '9' = true 7 16 func is_digit _ = false 8 17 9 18 func combine [a] = "${a}${a}"
+26
2025/1/p1.tri
··· 1 + import "trilogy:debug" use dbg 2 + import "trilogy:io" use readline 3 + import "trilogy:parsec" use parse, char_of, integer, apply 4 + 5 + proc rotation!() { 6 + let dir = apply <| char_of "LR" 7 + let amt = apply integer 8 + return if dir == 'R' then amt else -amt 9 + } 10 + 11 + func rotate amt pos = (pos + amt) % 100 12 + 13 + proc main!() { 14 + let mut zeros = 0 15 + let mut pos = 50 16 + while true { 17 + let rot = with parse rotation readline!() 18 + when 'eof cancel break unit 19 + else yield 20 + pos rotate= rot 21 + if pos == 0 { 22 + zeros += 1 23 + } 24 + } 25 + dbg!(zeros) 26 + }
+5 -1
Justfile
··· 43 43 cabal build {{part}} > /dev/null 44 44 else if test -f {{part}}.erl 45 45 erl -compile "$fn" 46 + else if test -f {{part}}.tri 47 + trilogy compile {{part}}.tri > {{part}}.ll 48 + clang-19 -O3 {{part}}.ll -o {{part}} 49 + rm {{part}}.ll 46 50 else if test -d {{part}} -a -f {{part}}/gleam.toml 47 51 pushd {{part}} 48 52 gleam build ··· 64 68 else if test -f {{part}}.pl 65 69 time swipl -s "$fn" -g main,halt < {{input}} 66 70 else if test -f {{part}}.tri 67 - time trilogy run "$fn" < {{input}} 71 + time trilogy run {{part}}.tri < {{input}} 68 72 else if test -f {{part}}.py 69 73 time python3 "$fn" < {{input}} 70 74 else if test -f {{part}}.rb