day 7 pt 1

nnuuvv f862b090 c98d08b3

Changed files
+47
src
aoc_2025
+47
src/aoc_2025/day_7.gleam
···
··· 1 + import gleam/dict 2 + import gleam/list 3 + import gleam/pair 4 + import gleam/set 5 + import gleam/string 6 + 7 + pub fn pt_1(input: String) { 8 + input 9 + // rows 10 + |> string.split("\n") 11 + // rows as chars 12 + |> list.map(string.to_graphemes) 13 + |> list.fold(#(0, set.new()), fn(acc, row) { 14 + let #(split_sum, columns_with_beam) = acc 15 + 16 + let #(splits, columns_with_beam) = 17 + list.index_fold(row, #(0, columns_with_beam), fn(acc, item, column) { 18 + let #(split_sum, columns_with_beam) = acc 19 + 20 + case item { 21 + "S" | "|" -> #(split_sum, set.insert(columns_with_beam, column)) 22 + "^" -> { 23 + case columns_with_beam |> set.contains(column) { 24 + True -> { 25 + let columns_with_beam = 26 + columns_with_beam 27 + |> set.delete(column) 28 + |> set.insert(column - 1) 29 + |> set.insert(column + 1) 30 + 31 + #(split_sum + 1, columns_with_beam) 32 + } 33 + False -> #(split_sum, columns_with_beam) 34 + } 35 + } 36 + // "." 37 + _ -> acc 38 + } 39 + }) 40 + #(split_sum + splits, columns_with_beam) 41 + }) 42 + |> pair.first() 43 + } 44 + 45 + pub fn pt_2(input: String) { 46 + todo as "part 2 not implemented" 47 + }