For day 10, the explanation of the problem is a bit convoluted and can be simplified quite a bit. The input given is an unordered list of unique numbers where each number accepts a value within the list that is between 1 and 3 lower than the current value.
The question asks for the number of differences of 1 and the number of differences of 3. If this does not make sense, we can take a look at the sample data.
16
10
15
5
1
11
7
19
6
12
4
Assuming that the count starts at zero, the…
For day 9, you are given a list of numbers. Starting from 26th indexed number, every number indexed further down is the sum of two numbers in the previous 25 numbers. The problem asks for which number is not a sum of any combination of the previous 25 numbers.
For the sample data, we will be starting with the 6th indexed number and the previous 5 numbers.
[1] 35 [2] 20 [3] 15 [4] 25 [5] 47 40 = (Range 1-5) [3] 15 + [4] 25 62 = (Range 2-6) [3] 15 + [5] 47 55 = (Range 3-7) [3]…
For day 8, the input data is a stack of instructions. The stack of instructions, when followed properly, leads to an infinite loop. You are given in the instructions that every line can only be run once and to return the value prior to the start of the second iteration.
The three instructions in the stack are ‘nop’, ‘acc’, and ‘jmp’. The first has no function and should only continue to the next instruction below it. The second will either add or subtract to the current value. …
Today’s puzzle is quite confusing on how to complete. If we take a look at the sample data:
light red bags contain 1 bright white bag, 2 muted yellow bags. dark orange bags contain 3 bright white bags, 4 muted yellow bags. bright white bags contain 1 shiny gold bag. muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. dark olive bags contain 3 faded blue bags, 4 dotted black bags. vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. faded blue…
For Day 6, you are given a string of characters that represent the answer “Yes” to a question labeled with a single character. There are 26 possible possible questions as there are the same number of letters in the alphabet.
In the input data, each person is represented on a new line and each group is represented with an extra space in between the input data. For example, if we were to look at the sample data:
abc
a
b
c
ab
ac
a
a
a
a
b
As there are letters on eleven lines, there are eleven people split…
For Day 5, you are asked to use parse through a string of 10 characters which point to a specific seat on a plane. The airplane has 128 rows and 8 seats per row. The first seven characters, made up of F’s and B’s, identify the row of the seat and the last three characters, made up of L’s and R’s identify the seat in the row. Each character halves the possible seats and tells whether to take the first half or the second half. Given the string:
FBFBBFFRLR
The first F refers to the first half of the 128…
Advent of Code’s Day 4 problem is going to be pure data validation with the second part being able to be done through regex. The input will be a string that looks something like this:
ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
byr:1937 iyr:2017 cid:147 hgt:183cm
This sequence represents a passport which needs to be verified if valid or invalid. There are eight fields in total.
byr = Birth Year
iyr = Issue Year
eyr = Expiration Year
hgt = Height
hcl = Hair Color
ecl = Eye Color
pid = Passport ID
cid = Country ID
For the first part of the…
For Day 3, you are navigating a map of ‘.’s and ‘#’s that represent a safe or unsafe point to drive through. The sample data is given as such below:
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#
The periods on the map represent a clear space to steer through, while a hashtag represents a tree. Given a slope, we are asked to find the number of trees that one would encounter while traversing to the last line of the map. We are also told that once we run off the right side of the map, the…
For Day 2, you are given a list, each with their own rules and asked to return the number of lines that are valid.
1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc
In the example provided, you are given three lines. The numbers before and after the dash tell you how many times the following letter should appear in the string on the right side of the colon. In the line: 1-3 a: abcde
, the letter a should appear between one and three times in the string after the colon.
For the example above, the answer would be 2…
Advent of Code is a series of 25 coding puzzles that are released daily between December 1 to December 25. It is free and open to everyone to participate and since it started in 2015, has grown to have a large community of thousands of users with a dedicated subreddit. In this series of blogs, I will try to solve each day’s problem set similar to how I would answer on a technical interview.
For Day 1, the problem is to find two numbers in a list that sum to 2020 and give the product of those two numbers. As…