# https://adventofcode.com/2022/day/1
= readlines("day_1_ex.txt") example
14-element Vector{String}:
"1000"
"2000"
"3000"
""
"4000"
""
"5000"
"6000"
""
"7000"
"8000"
"9000"
""
"10000"
Day 1
November 27, 2022
Advent of code is a fantastic opportunity for programmers to hone their skills. Here’s a solution in Julia for Day 1, 2022.
Start by loading data for the sample and our full input.
14-element Vector{String}:
"1000"
"2000"
"3000"
""
"4000"
""
"5000"
"6000"
""
"7000"
"8000"
"9000"
""
"10000"
Today’s challenge involves counting the inventory of each elf. A logical starting point is to consider the data structure. A simple vector of vectors should well represent all items of all elves.
Inventory
has field items
which will hold all the items of a particular elf. In order to create the desired vector of vectors, we want the input to be split by new lines. It is easy to write a function which takes in some vector and splits it by some function.
We can now write the function that will parse our challenge input into the desired data structure.
So, we have everything we need to describe the full elfish inventory. All that’s left is to describe the method of finding the top elf. We can do this in a general way so that we can elect how many of the top elves are returned.
Parts one and two differ in the number of top elves required. We can write separate functions to accomodate this.
Time to solve!