{:ok, content} = File.read("input-2") content = content |> String.split("\n", trim: true) |> Enum.map(fn n -> String.graphemes(n) end) count2 = 0 count3 = 0 for line <- content do Enum.reduce(line, %{}, fn char, acc -> Map.put(acc, char, (acc[char] || 0)+ 1) end) |> Map.values |> Enum.filter(fn x -> x == 2 || x == 3 end) # need to split and count occurance of 2 and 3 seperately |> Enum.reduce(0, fn x, acc -> if x == 2 do acc + 1 end end) end |> IO.inspect IO.puts(count2) IO.puts(count3) # File.stream!("input-2") # |> Stream.map(&String.trim/1) # |> Stream.map(fn n -> String.graphemes(n) end) # |> Enum.reduce(%{}, fn char, acc -> # Map.update(acc, char, 1, &(&1 + 1)) # end) # |> IO.puts