optimise: no numbers start with r or x

This commit is contained in:
Adam Millerchip 2023-12-02 00:16:19 +09:00
parent 27babd9ed7
commit 3d68fa4048

View file

@ -26,9 +26,9 @@ defmodule Day1 do
def filter_digits2(<<"one", rest::binary>>), do: "1" <> filter_digits2("e" <> rest) def filter_digits2(<<"one", rest::binary>>), do: "1" <> filter_digits2("e" <> rest)
def filter_digits2(<<"two", rest::binary>>), do: "2" <> filter_digits2("o" <> rest) def filter_digits2(<<"two", rest::binary>>), do: "2" <> filter_digits2("o" <> rest)
def filter_digits2(<<"three", rest::binary>>), do: "3" <> filter_digits2("e" <> rest) def filter_digits2(<<"three", rest::binary>>), do: "3" <> filter_digits2("e" <> rest)
def filter_digits2(<<"four", rest::binary>>), do: "4" <> filter_digits2("r" <> rest) def filter_digits2(<<"four", rest::binary>>), do: "4" <> filter_digits2(rest)
def filter_digits2(<<"five", rest::binary>>), do: "5" <> filter_digits2("e" <> rest) def filter_digits2(<<"five", rest::binary>>), do: "5" <> filter_digits2("e" <> rest)
def filter_digits2(<<"six", rest::binary>>), do: "6" <> filter_digits2("x" <> rest) def filter_digits2(<<"six", rest::binary>>), do: "6" <> filter_digits2(rest)
def filter_digits2(<<"seven", rest::binary>>), do: "7" <> filter_digits2("n" <> rest) def filter_digits2(<<"seven", rest::binary>>), do: "7" <> filter_digits2("n" <> rest)
def filter_digits2(<<"eight", rest::binary>>), do: "8" <> filter_digits2("t" <> rest) def filter_digits2(<<"eight", rest::binary>>), do: "8" <> filter_digits2("t" <> rest)
def filter_digits2(<<"nine", rest::binary>>), do: "9" <> filter_digits2("e" <> rest) def filter_digits2(<<"nine", rest::binary>>), do: "9" <> filter_digits2("e" <> rest)