Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Day 10

day10.livemd

Day 10

Setup

Mix.install([
  {:kino, "~> 0.4.1"}
])
Example input:
[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]
Real input:
[({<(({{(([([[{}{}](<>())][<(){}>[[][]]]){{(<>{})<{}()>}}](<<<()<>><()<>>>([<>[]])><{<[][]
<<([{([<([{<<{[]<>}([]{})>><{(<>{})([][])}[[{}]((){})]>}([[([]<>)[<><>)]{<{}[]>{[]()}}]<<[{}{}]<<>{}>>{[{}<>]
{<<[(<{<({[{[{[][]}{[]{}}](<[]<>>[<><>])}]}[<{(<<>{}>(()()))<(<>{})(<>())>}>{{{{()()}{<>}}}}])><<{{<{[
{({([<<<[<<<<[{}{}][<>]>[(<><>)]>[<{{}()}<[]<>>>]>>([{[[()<>]{[]<>}](([]{})[<>()])}(((())[{}])[{<>()}
[{[<[{[(([{({[()<>](<>())}[{<><>}[[]()]])((<{}[]><()[]>>[[<>{}]{<><>}])}<[<{{}[]}{()()}>{(
{<<{{[{{({{((([]()){{}()})){(<{}[]><()>)(<<>[]><[]<>>)}}[[[<()<>>][<()<>>(()())]]<[[[]<>]{
[{({[{[{[[<[<[<>{}]<[]>>{<<>[]><{}[]>}]>[[[[[]<>><<>{}>](<{}[]>[{}<>])]{<{<>{}}(<><>)><<{}[]>(<><>)>}]]<{{{{[
<<<{((({<<<[[[()<>]<[]()>](<{}()>)](({[]{}}<<>()>){{[]{}}})>{[[[{}[]]<{}{}>]{[[][]]{<>()}}]}><
({[<<{<({{[[(({}[])[<>()])<<{}[]>[[]<>]>]([{{}[]}<{}[]>]<{()[]}<{}()>>)]<[{<[]()>[{}{}]}{[()[]]}]<
([([[{[((<[[<[<><>][(){}]>[(()[])]]]<{<{[][]}([]())>([{}][<>{}])}<(<[][]>[(){}])(([][])<<>()>)>>><[
{<[<<([(([<([[{}[]](()())]<{<>()}>)[<(<>{})<<>{}>>{{[][])[()<>]}]>[[({<>{}}([]{})){[()()]}][{[<>]}(
([<[<[([([[[<<<>{}>><{()()}[{}[]]>]({<<>[]>{<>()}})](((<<>{}>{{}()}))<[([]<>){{}{}}]>)][{(
[[({(<[{<(([<{(){}}>)({<()[]><<>()>}<<()[]><<>>>))[{({(){}})(<{}<>>{[]<>})}[[([]())[()[]]]]])([<
[<<<{[({[<[<{[{}[]][[]<>]}>{<{{}<>}>({()[]}[{}[]])>]([<[{}()]<{}[]>>{[{}()]}]{[[(){}]{<>}]<<<
{[<[({((([(<{({}())}([{}[]]{<>[]})><[[[]{}](()())]{{<><>}{[]{}]}>)[[({<>()}<()()>)([()<>][()<>]
<<({({[[(<(<{[<>[]]({}{})}>)[<[{(){}}[{}[]]]<{<><>}>>]>{<(([()]<(){}>)([{}<>])){(<<>()>{[]()})(<{}{}>{{}{}
<{({(<<{[[{<{[<>()]{<>[]}}>}([{{<>[]}{[]()}}{{{}{}}{<>[]}}])]<<(((<>[]))<<[]()>[()()]>)<<<{}{}>>{<()<
{([{{[{<<<{<[{()()}{<>}][{[][]}{[][]}]>}<<[((){}){{}()}]{{(){}}{[]<>}}>[{<{}[]>}<{[][]}{{}[]
{{[((<[[[<{([<()[]>[()[]]]{[<><>][<><>]})([{()}][{<>[]}{{}[]}])}[[[<{}{}>({}{})]{<()<>>({}[])}]<
{(({[((<{(<{<<<>[]>{{}<>}>}(([(){}]<[]<>>))>[[(<<>>{<><>})(({}<>)(()<>))]])}>([<[(<[{}<>][[]<>]>[(
<{{[(<<{{(<({<<><>>({}())}[<[]()><<>[]>]){{(()()){<><>}}[({}{}){[]<>}]}>{(<<{}()><()()>>{{<>{}}{{}<>
{{<{({{{([{<({{}<>}{[][]}){{()[]}}><{{[]}{<>{}}}[{()<>}[<>[]]]>}[{([()]){({}<>)[<>{}])}(<<[][]>[()[]]>([
[{<(<({<<[[(<[[]{}]({}{})><<()<>>{[]()}>)({<[]()>([]())}{{[]{}}{<>[]}})]]{[(<{{}[]}{[][]}><[(){}]<<><>>>)]}>>
{<<(<({<{[<[{<()<>>}]<{[<><>]{[]{}}}<{<><>}>>>([[<[]()><{}()>]{{<>[]}>](<[<>{}]<[]{}>>[[()[]]{[]{}}])
<({<{<[{([<(({{}()}(<>()))([<><>]{[][]}))><<[<[][]>{()()}]>>]){[[({{[]}}{[()()]}){[(()[])[{}()]](([]<>){<><
[({{([<[({<((({}[])(<>()))<[<><>][{}{}]>)[[([]{})<<><>>]((<>{})([]{}))]>(([[[]()}{<><>}][{()[]}]){{<{}{
<{({[[{({((({([]<>){<>[]}}{{<><>}})(({()<>>[[]{}])<(()[])[[]{}]>)))})[{<<({[<>()]})([[()[]]<{}
{({(<(<([{{{(<{}>)<{[]()}[[]()]>}[([<>{}]{[]()})[[{}](<>[])]]}{[({{}{}}[{}()])([{}()]{<>[]})]{[(()[])(()
{<{{<[[({[{<({()<>}{()<>})>{[{()[])[()[]]]}}][({<<[]<>>[()[]]><<{}<>>[{}()]>})]})<[({<({[]()
<<(<{[<[(({{<(()[])<{}{}>><(<>{})<{}[]>>}[<([]())({}{})><<()[]><()[]>>]}<[[{(){}}{<>()}]{((){}){<><>})]<
<<<((([{({<{<[(){}]{(){}}>}{<(()<>)<{}{}>>}>[([<<>()><<><>>])<(([]{})){<{}[]>[{}()]}>]}[{{<<()[]>(
({{([[<[[<<{({()()}({}[]))}[{(()[]){{}<>}}{([]<>)(()())}]><<{{{}[]}}{[[]](()()>}>{<({}[]){[]
<[<[[<[[<{{{<{<>()}[()[]]](<{}[]><<>[]>)}<<<{}()>([]<>)>{([]{}){[]<>}}>}([{{<><>}[[][]]}{[<>
{[[{[<{{[{{[[<{}[]><<>>]]}<<<{()()}([]<>)>{<<>[]>[<>[]]}>([{()[]}{[][]}]{{{}{}}(<>{}}})>}<((<<()[]>>[<()()><[
([(<{(({[([([[{}]])]({<(()())<<>{}>>}<<{{}()}>[<<>()><<><>>]>))<{{{{()()}[(){}]}>}>]})<[<<{<[<{}{}><{}{}>]{{
{{{<[{{([<[<([{}[]]({}<>))[([]())]>](<(<()()>[<>])>{[(()<>)]({<>[]}(<>{}))})>{({[{[]<>]<{}{}>]<[{}<>]<<
<{<<<([([{<[(([]{})(<>)){(<>{})<<><>>}]{({<>[]}{{}()}){{{}{}}{{}()}}}><[<(()){[][]}>{<{}{}>{<>()}}]>}][[
([({{({{([[{[{[]()}{[]{}}]<<[]<>>(()<>)>}[((<>{})[<>()])[[{}()]<<><>>]]]][<[<(()<>)(<>)><[<
[<<{[(<[<<{{{<<>{}><<>[]>}}}>((<[[()<>]<<>()}]<(<>()){<>()}>>([(()<>)([]{})][[(){}]{{}{}}]))[{[[[]{}]]<
<{<{<<[([[(<[[[]()]<{}{}>][{[]<>}(()[])]]({{<><>}(()[])}{([][])(()())}))(<[[<>{}]][{()<>}]>)][<{<(
[{[[[[((<[[((<[][]>{(){}})[{()()}])]{<<{(){}}>{(<><>)(()[])}){<[()]<[]()>>}}]>))[[<{([{{()<>}{()
([{({<<{[(([(<[]<>>{[]()})](<{{}{}}[()()]>)))[[<{({}())}{<()[]>}>](<([[]{}][<>{}])<{{}{}}[()[]]>>[<
([[<{[[{[[<{{[{}[]](<>{})}([()<>](()[]))}>(([{[][]}<<>()>]((<>{}){<>[]})))]([([{{}[]}([]()))(<{}()><<><>>))[
(<<[{<<<{(<<([()][(){}])({[]{}})>{<{{}<>}{()()}><[{}[]](<>[])>}>{[[{()()}[[]<>]]<<{}()><[]{}>>](<{<>[]}>{<<><
{<(<({{[({[{{{(){}}[<>[]]){[<><>]{[]()}}}<<[[]<>]{{}<>}>{((){})([][])}>]}<{<((()){[]()})<{<>(
[[[((({{[[{(<[[][]]((){})>){[([]{})]<<{}<>><()[]>>}}<((<()()>))[{([]())([][])}[<()>{(){}}]]>][{(<<<>()><(){
{<<<{{(({{{<({{}[]}({}<>))<{{}}>><({<>{}}{<>{}})>}[([[<><>]<[]>](({}{})<(){}>))([<{}[]>[()[]]]
[((([(([{{{([{<><>}]<((){}){{}[]}>)<([()[]]{[][]})<{{}()}{[][]}>>}}}(<<<<<()<>>[{}[]]>>>{<[
[{(<[[{{({(({((){})((){})}{(<>{})<[]{}>})([(()[])<()[]>]))[([{()[]}[[]<>)])<{{()<>}(()())}<{[][]}[{}<>
<(<(<([(((<{(<<>{}>[<>{}]){<{}<>>({}<>)}}(<<<>[]>[()()]><{[][]}>)>)))[<{(<{([]{})[[]{}]}[<{}{}><()()>]
<<(<([<[(<<{[[()[]]([]{})]}[[((){})<{}()>]<<[]<>>({}<>)>]><(<{<>()}<[]{}>>(<{}{}>(()<>)))>>){{([<([]{})<{}{}>
<{<{{{(({{<[[([]<>){{}<>}]{{[][]}}]>{<<{()<>}({}[])>{{{}()}{(){}}}>}}[<(<([]())<<>()>>[{[]}{<>[]}]){[[{}<
[{(<(({(<<{[[({}()){<>{})]]}[[{[<>[]][{}[]]}]((([][])<(){}>)[{[]{}}(<>())])]>>[(((({(){}}<{}>)(<{}{}><[]
{(([[[(<<<<<{<<><>><{}[]>}[[[]{}]([]<>)]>{{{<><>}<[]{}>}[<{}<>><()<>>]}>>[{{<{<>}(()<>)>[{{}<>
{([{[([<[<<[[(()()){()()}](([]()){<>()})]>({<<{}()><<>()>><[<>{}]{{}<>}>})>]{{(<(<[]<>>{<>
{(({{<[[{([[{[[]()][{}{}]}{[()<>]<()[]>}](<({}[])>{[[]{}]<<>[]>})]{{({{}<>}<(){}>){<{}()>({}{})}}[[{
{(((<<{<([[{([()[]][[]<>])}{{[<>{}]<{}()>}<<<>[]>[<>{}]]}](({[()()](<>{})}[<()>]))]{{[[[[]<>]{<>
([[[({{(([{{([<>{}]){<{}{}><{}[]>}}<[[(){}][[]{}]][(())[<>{}]]>}])[{([{{<>()}[[]<>]}{[[]()]{[][]}}]{{{
{[<(<<{<{<[([(()())[<>()]]{{{}<>}{[]<>}})]>}>}{{<([<<<[]()><{}()>>([[]()]([]()))><{<<><>>([]<>)}<(<>
<[<(((<[(<[[[<<>[]>{()[]}][{[][]>(<>)]](<{<><>}[()]>)]>{<{({{}{}}[{}{}]){[[]<>]<{}>}}[{({})
[{<[[[<[[[<[{[<>[]]{[]()}})<<[[]()]{[][]}>([[][]]{()()})>>]]([[({[<><>][<>]}{<<>()>([])})<([{}<>][<>()])<(
{((<[<(<(({([(()<>){[]}]<[{}<>]{()<>}>)([([]{})][{(){}}[[]<>]]]}<<{{()<>}(()[])}<(<><>)<()>>>>)({{[<(){}>[
[([{<((([[<<[{{}{}}({}<>)]>><<[[[]()](<>())]>>]([([({}<>)](<{}<>>))<[[{}{}]]>]<[<[[][]]{()()}><{{}<>}((){})
([[[{{[[({{{{{()<>}{[]{}}}}[<<()[]><[]{}>>[[<>()]]]}{<[{(){}}(<>())][<{}<>><[][]>]>{<([]{})[()()
[<(<<({(<[[{[{()()}{{}{}}][[<>()>]}{[[<>{}](<>[])]}]([{([][])<()>}{<<>()>[()<>]}]{{[[]][[]<>
[<<({([<{[{(([{}()]<<><>>))}[({<[]()>([]{})}[{()()}(()<>)])(<([][])(())>{<[]()>{[]{}}})]]{[<({<><>}<[]
<{({(<{{(<{([[<>{}]])<<[()[]]{<>{}}>>}{[((()<>))<(()())>][{{[]{}}[<>()]}(<<>{}>[()()])]}]{{({<{}
(<{{[<[[{[<{{[{}()]}{({}{})}}(<{[]()}({})><<[]{}>(<>[])>)>](<{[(())({}{})]((<>[]){()<>})}[{[[]<>][{}[]]}[
(<<{<[[{(([{[(<>{})([])]<[<>()][<>[]]>}]<[([[]()](()[]))({(){}}<(){}>)]<{{{}{}}<[]<>>}<([])([]<>)>>]))}]{
[([{({{((<[[([{}[]]{<>}){(()[])([]{})}][{<{}<>><()()>}]]<([(<>{})[<>[]]])]>))}[((({(([[][]
<[{<<[{{<{{[{[()()]{()[]}}][([{}<>]<()<>>)<[{}{}]>]}{<[(()<>)][((){})({}())]>((<<>{}><<>()>)<[{
([[{[<[{[<[([({}[]){{}()}]){({[][]}(()))[<[][]>{{}<>}]}]>]}(({{({<{}<>>[[]<>]}{{()}})({[<>()]}<{{}}>)}[
([[[<[<(<<<[{{[]}<<>{}>}[(<><>){{}[]}]><[{{}<>}<()()>][[{}()](<>{})]>><[{{()[]}<{}>}<[<><>]({
([(([[[<{<<<{([]){[][]}}{(<>[])[{}()]}>[<(()[])[()[]]>(<()<>>(()<>))]>([<{<>{}}<{}[]>>(<()[]><{}
(<[{<<(<<({<[(())([]<>)][<()[]><{}<>>]>({<{}{}>{{}}}{(<>[])<[]{}>})}){[({[()()][[]{}]}[<<>[]>{{}
({[{(<(([(<[{<[]<>>(()())}[(())[{}<>]]]<{{()[]}{()()}}>>[<<[{}{}][{}{}]>((()()>[{}()])>[[<<>{}>(<
(([(<<([<[({(<{}()>)({<>{}}({}<>))}[({{}<>]{[]()})<{[]<>}>])<<[{{}()}{()<>}]{<()()>{<>()}}
[((<{<([{{<<<(()[])(<>())>{<{}()>(<>())}>[<<[]>({}())>]>({<[{}<>]{<><>}>})}}])<<[<{([{[][]>{()()}
<[({(<[{{[[(((()<>)<{}[]>){<[]()>[[]()]})<[[{}()](()<>)]<((){})>>]]<(({(<>[])([]{})}[{()}[()()]
(<[{[<(<[([[(<(){}>{{}())){(<>{})[{}()]}]<<({}[]){[]()}>(({}{}){{}{}})>](<{<[][]>([]())}[<()>{<>
{<[[<((((({({[{}[]]{<><>}}({<>()}{{}<>}))([[()()]([]{})]{[{}]{<>()}})}{<((<><>)(<>[]))[[{}()][{}[]]]><<[<>{}]
[[[{{{(<<([(<(()[])<[]{}>>[[<>{}]<{}>]){<{[]()}(()<>)>([{}[]][{}<>])}])(<{<<{}[]>{<>{}}>([()[]]<{}{}>)
{<[(({[[((([{(<>[])<<>[]>}[<()[]><{}{}>]](<([]{})(<><>)>{{()}({}[])}))))([[(([<>{}][{}()]))<{{{}()}<{}[]>}
<<<<<<<[{<[({{{}[]}<<>>}[<{}<>>([])>)<{({}[])}<({}())>>]{{{{{}()}}}}>{<[(({}[])(<><>))](<{()<>}>([{}{}][[]{}
[[(<(<{<([(<[[[]{}]{[]{}}]<[{}<>]<{}<>>>><{<()[]>({}())}([()[]]{()})>){{{{<>{}}<()<>>}(<{}()>([]
(<<([<(([([{[[<>[]](<><>)][[<><>]{{}[]}]}[{<()()>}]]){([((()()){<>{}})(({}()}([]<>))]{<{<>()}(
({({<(([(([(({{}<>}{(){}}){{()[]}[{}<>]})[[{()()}{()()}]((()))>]{({([]{}){{}[]}}{<{}()>[{}()]})(<[[]{}]{
[{[{<[[((<[(((<>[])([]<>>)({()<>}))][{<({}[]){<>{}}>}(<{<><>}{{}{}}>{<()[]>{(){}}})]>))[{{{
[<(({[<<<{(<[<(){}>{[][]}][[()<>]<{}{}>]>{{<[]{}>[()[]]}{({}[]){[]<>}}})((({<><>}(()))[([]{})]))}{<<({{}{
({([<{{((<({([{}<>]([]{}))(<[]<>>{[]()})}<[([]{})[[]{}]][(()<>)<[]<>>]>)[(<{[]<>}<{}()}>[({}<>)<<>{
[<[(<{([(([(<[{}{}]{{}[]}>[([]())[()()]])(<{(){}}{{}{}}>)])([{<<[]{}>>{{[]()}[{}{}])}][{{{{}<>}}}
{(<{((<[[[({[((){})]}{<({}<>)(<>())>[<{}<>>([]<>)]})][{<{<[]{}>{()[]]}(([]{})<<>()>)>([{{}<>}<[][]>]{
<{(([<([({[(<(<>{})[[]<>]><[[][]]<{}[]>>)](<{{{}<>}(<>())}<[<><>]([]())>>([[()[]]<<>{}>]))}<
{{([<<({[[<<<{()[]}<{}()>>[[(){}>{<><>}]>[[{[]}]{({}<>){{}{}}}]>[[{<[]<>><()<>>}<{<>()}>]<{
([{<{<((([<[(<[]{}><<>()>)(({}<>)[[]<>])]><{[(()())[()()]]}>]<({{<<>[]>[<>{}]}[[()<>]]])[[<({}[])({}<>)><
[<[([(<([[<[[[()[]][[]<>]][<{}<>>]](([{}{}])[{[]{}}({})])>[<<({}()){<>[])>{<<><>>(<><>)}>]]{{{{({}<>)<<>
<<({[<{[({{[[<[]()><<>>][<()[]>[{}<>]]]}<{<[(){}]{[]{}}>({{}<>}[<>[]])}{<{[]()}<<>()>>{(<>[])[{}
{{<{({{([{<<<{<>[]}(<><>)>[<<>[]>({}{})]><<{()}[{}[]]>[<()[]>{<>{}}]>>{{[<{}()>(<>[])]}[(<[]()>(()))
[({(([(([{<<{[<>{}]({}{})}{[[]()]{[]{}}}>>}}<{<{<((){})(<>[])>{([]())<{}<>>}}<[<()>][<(){}>{
(<<[<<({([([(<[]<>>{{}()})([()<>][()<>])](<({}{}){<>{}}>{(<>{}]{{}()}}))]{{[[([]())<[]<>>]
<[[{{({{{<<[<<[][]>{<>()}>{{()()}([]<>)}]<[{()[]}{()}][[[]]]}>>}<<[{{{<>[]}<<>{}>}({{}()}{[][]}
[{<{[[<[<([((<{}<>><<><>>){<[]{}>[{}{}]})[[([])[[]()]]({<><>}<(){}>)]]{<((()[])([][])){(<>())([][])}>[{
<(([{<[<<[{<[[[][]]](<[]<>><<>[]>)>([{(){}}{{}[]}]{<<>[]><{}()>})}<{{([][])[{}<>]}{{{}()}}}[<(<
<<{((([<[(<[{<[]()>}{(())<()<>>}]>[{<[<>()]{()<>}>[{<><>}{[][]}]}{[<{}{}>({}<>)]{{[]()>{[]<>
[[[{[[[{{<(<{{[]<>}[<><>]}({()()}[()[]])>[((<>[])(<>)){{()<>}([][])}])[{{{[]<>}<()[])}({<>[]})}(({
{<<<(<(((({[[([])([][])]<<[]<>>>]}{{<{{}[]}(<>[])><{[][]}[[]{}]>}<{<()[]>}<{[]{}}{()<>}>>})){<<<[{[]<>}[[]
input = Kino.Input.textarea("Puzzle Input")

Process Input

lines =
  input
  |> Kino.Input.read()
  |> String.split("\n", trim: true)
  |> Enum.map(&amp;String.to_charlist/1)

nil

Part 1 First Try

lines
|> Enum.map(fn line ->
  Enum.reduce_while(line, [], fn char, acc ->
    [last | remain] = if length(acc) > 1, do: acc, else: [List.first(acc) | []]

    cond do
      char in [40, 91, 123, 60] -> {:cont, [char | acc]}
      char - 1 == last or char - 2 == last -> {:cont, remain}
      true -> {:halt, char}
    end
  end)
end)
|> Enum.map(fn char ->
  %{41 => 3, 93 => 57, 125 => 1197, 62 => 25137}[char]
end)
|> Enum.reject(&amp;is_nil/1)
|> Enum.sum()

Part 2 First Try

lines
|> Enum.map(fn line ->
  Enum.reduce_while(line, [], fn char, acc ->
    [last | remain] = if length(acc) > 1, do: acc, else: [List.first(acc) | []]

    cond do
      char in [40, 91, 123, 60] -> {:cont, [char | acc]}
      char - 1 == last or char - 2 == last -> {:cont, remain}
      true -> {:halt, char}
    end
  end)
end)
|> Enum.reject(fn result -> result in [41, 93, 125, 62] end)
|> Enum.map(&amp;Enum.reverse/1)
|> Enum.map(fn line ->
  Enum.reduce(line, [], fn char, acc ->
    value = %{40 => 1, 91 => 2, 123 => 3, 60 => 4}[char]
    [value | acc]
  end)
  |> Enum.reduce(0, fn val, acc -> acc * 5 + val end)
end)
|> Enum.sort()
|> then(fn scores -> Enum.at(scores, div(length(scores), 2)) end)

Process Input Jose Way

lines =
  input
  |> Kino.Input.read()
  |> String.split("\n", trim: true)

nil

Module Jose Way

defmodule Syntax do
  def parse(line), do: parse(line, [])

  # Opening
  defp parse(<rest::binary>, stack), do: parse(rest, [?) | stack])
  defp parse(<rest::binary>, stack), do: parse(rest, [?] | stack])
  defp parse(<rest::binary>, stack), do: parse(rest, [?} | stack])
  defp parse(<rest::binary>, stack), do: parse(rest, [?> | stack])

  # Closing
  defp parse(<>, [char | stack]), do: parse(rest, stack)

  # Base/Error cases
  defp parse(<>, _stack), do: {:corrupted, char}
  defp parse(<<>>, []), do: :ok
  defp parse(<<>>, stack), do: {:incomplete, stack}
end

Part 1 Jose Way

points = %{
  ?) => 3,
  ?] => 57,
  ?} => 1197,
  ?> => 25137
}

Enum.sum(
  for line <- lines,
      {:corrupted, char} <- [Syntax.parse(line)],
      do: Map.fetch!(points, char)
)

Part 2 Jose Way

points = %{
  ?) => 1,
  ?] => 2,
  ?} => 3,
  ?> => 4
}

scores =
  for line <- lines,
      {:incomplete, chars} <- [Syntax.parse(line)] do
    Enum.reduce(chars, 0, fn char, acc -> acc * 5 + Map.fetch!(points, char) end)
  end
  |> Enum.sort()

Enum.fetch!(scores, div(length(scores), 2))