Regex was overkill
This commit is contained in:
parent
6f332192cb
commit
3784d613f6
2 changed files with 2 additions and 2 deletions
|
@ -9,7 +9,7 @@ defmodule Day8Part1 do
|
||||||
def input_to_instrs(input) do
|
def input_to_instrs(input) do
|
||||||
input
|
input
|
||||||
|> String.split("\n", trim: true)
|
|> String.split("\n", trim: true)
|
||||||
|> Enum.map(&Regex.run(~r/\A(\w{3}) ([+\-]\d+)\z/, &1, capture: :all_but_first))
|
|> Enum.map(&String.split/1)
|
||||||
|> Enum.with_index()
|
|> Enum.with_index()
|
||||||
|> Map.new(fn {[op, arg], idx} -> {idx, {op, String.to_integer(arg)}} end)
|
|> Map.new(fn {[op, arg], idx} -> {idx, {op, String.to_integer(arg)}} end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ defmodule Day8Part2 do
|
||||||
def input_to_instrs(input) do
|
def input_to_instrs(input) do
|
||||||
input
|
input
|
||||||
|> String.split("\n", trim: true)
|
|> String.split("\n", trim: true)
|
||||||
|> Enum.map(&Regex.run(~r/\A(\w{3}) ([+\-]\d+)\z/, &1, capture: :all_but_first))
|
|> Enum.map(&String.split/1)
|
||||||
|> Enum.with_index()
|
|> Enum.with_index()
|
||||||
|> Map.new(fn {[op, arg], idx} -> {idx, {op, String.to_integer(arg)}} end)
|
|> Map.new(fn {[op, arg], idx} -> {idx, {op, String.to_integer(arg)}} end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue