escapedList = File.stream!("inputs/day8.txt") savings = Enum.map(escapedList, fn rawString -> savedFromEscapes = Regex.scan(~r/(\\\\|\\"|\\x[0-9a-f]{2})/, rawString, capture: :first) |> Enum.map(fn [escape] -> String.length(escape) - 1 end) |> Enum.sum() 2 + savedFromEscapes end) |> Enum.sum() IO.puts("Potential savings: #{savings}") bloat = Enum.map(escapedList, fn rawString -> bloatFromNewEscapes = Regex.scan(~r/(\\|\")/, rawString, capture: :first) |> Enum.count() 2 + bloatFromNewEscapes end) |> Enum.sum() IO.puts("Potential bloat: #{bloat}")