Skip to content

Commit

Permalink
Solve day1 function fail!
Browse files Browse the repository at this point in the history
  • Loading branch information
samjowen committed Dec 22, 2023
1 parent 51404b3 commit 829693b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
14 changes: 6 additions & 8 deletions lib/advent_of_code2023.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ defmodule AdventOfCode2023 do
Documentation for `AdventOfCode2023`.
"""

@doc """
Hello world.
@spec day1_solve() :: number()
def day1_solve() do
string_list = Day1.parse_file("lib/day1/data/input.txt")

## Examples
number_list = Day1.parse_list_to_first_last_numbers(string_list)

iex> AdventOfCode2023.hello()
:world
summed_tuple_list = Enum.map(number_list, &Tuple.sum/1)

"""
def hello do
:world
Enum.sum(summed_tuple_list)
end
end
2 changes: 2 additions & 0 deletions lib/day1/day1.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ defmodule Day1 do
input_list |> Enum.map(&find_first_and_last_number/1)
end



# End module
end
17 changes: 9 additions & 8 deletions test/day1_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ defmodule Day1Test do
]
end

# test "parses list of strings into first and last number tuples" do
# list = Day1.parse_file("./test/mocks/lines_of_text_w_numbers.txt")
test "parses list of strings into first and last number tuples" do
list = Day1.parse_file("./test/mocks/lines_of_text_w_numbers.txt")

assert Day1.parse_list_to_first_last_numbers(list) == [
{1, 3},
{4, 6},
{7, 9}
]
end

# assert Day1.parse_list_to_first_last_numbers(list, :string) == [
# {1, 3},
# {4, 6},
# {7, 9}
# ]
# end
end

0 comments on commit 829693b

Please sign in to comment.