Advent of Code solutions

implement p2 in trilogy now that its working!

+34
+34
2025/1/p2.tri
··· 1 + import "trilogy:debug" use dbg 2 + import "trilogy:io" use readline 3 + import "trilogy:number" use abs 4 + import "trilogy:parsec" use parse, char_of, integer, apply 5 + 6 + proc rotation!() { 7 + let dir = apply <| char_of "LR" 8 + let amt = apply integer 9 + return if dir == 'R' then amt else -amt 10 + } 11 + 12 + func rotate pos amt = 13 + if abs amt > 100 14 + then yield 'full(abs amt // 100); rotate (amt % 100) pos 15 + else pos + amt 16 + 17 + proc main!() { 18 + let mut zeros = 0 19 + let mut pos = 50 20 + while true { 21 + pos = with rotate pos <| parse rotation readline!() 22 + when 'eof cancel break unit 23 + when 'full(n) then { 24 + zeros += n 25 + become unit 26 + } 27 + else yield 28 + if pos < 0 || pos > 99 { 29 + zeros += 1 30 + pos = (pos + 100) % 100 31 + } 32 + } 33 + dbg!(zeros) 34 + }