Post B0wMi8JW77POAzLC1g by layarlaut@misskey.id
 (DIR) More posts by layarlaut@misskey.id
 (DIR) Post #B0wMi8JW77POAzLC1g by layarlaut@misskey.id
       2025-12-05T13:59:33.367Z
       
       1 likes, 0 repeats
       
       Finally done with day 1. Phew, writing in Par was quite a challenge, as I need to relearn how to code again. It looks nicer than I expect with such alien syntax#adventofcode dec SolveA : [Iterator<either{},Rotation>] Intdef SolveA = [iterator]let count = 0 inlet sum = 50 initerator.begin.next.case {.end res => res.case{.err e => e.case {},.ok! => count,},.item(rot) rest => rot.case {.left n =>let sum = Int.Mod(Int.Sub(sum, n), 100) in Int.Equals(sum, 0).case {.false! => rest.loop.true! => Int.Add(1, rest.loop)},.right n =>let sum = Int.Mod(Int.Add(sum, n), 100) inInt.Equals(sum, 0).case {.false! => rest.loop.true! => Int.Add(rest.loop, 1)}} }dec SolveB : [Iterator<either{},Rotation>] Intdef SolveB = [iterator]let count = 0 inlet sum = 50 initerator.begin.next.case {.end res => res.case{.err e => e.case {},.ok! => count,},.item(rot) rest => rot.case {.left n =>let now_on = Int.Sub(sum, n) inlet pass_zero = Int.Compare(now_on, 0).case {.equal! => 1,.less! => Int.Equals(sum, 0).case {.false! => 1,.true! => 0,},.greater! => 0} inlet sum = Int.Mod(now_on, 100) in let pass = Int.Abs(Int.Div(now_on, 100)) -> Int.Add(pass_zero) inInt.Add(pass, rest.loop),.right n =>let pass = Int.Div(Int.Add(sum, n), 100) inlet sum = Int.Mod(Int.Add(sum, n), 100) inInt.Add(pass, rest.loop),} }