Advent of Code 2018 - Day 3

Problem 1 My understanding of day 3’s first problem is this: given a string that is a list of fabric claims like "#1 @ 1,3: 4x4\n#2 @ 3,1: 4x4\n#3 @ 5,5: 2x2" on a large grid of fabric (with the coordinates starting at the top left), return an Int which is the number square inches claimed more than once. The sample data returns 4. Method To solve this problem I needed:...

December 4, 2018 · 7 min

Advent of Code 2018 - Day 2

Problem 1 My understanding of the second day’s first problem was this: given a list of IDs like "abcdef bababc abbcde abcccd aabcdd abcdee ababab", return a checksum which is the number of IDs that contain exactly two of the same character times the number of IDs that contain exactly three of the same character. IDs can count towards both numbers. The sample returns 12. Method Break up the input into an array of the individual IDs Write a function that takes a string and a count (int) and returns a bool that is whether that string contains exactly “count” of any letter Filter the array using that function for count 2 Filter the array using that function for count 3 Multiply the counts of the filtered arrays together Implementation Again, I start my function by saying let array = string....

December 3, 2018 · 5 min

Advent of Code 2018 - Day 1

Problem 1 My understanding of day 1’s first problem was this: given a string like "+1, -2, +3, +1" , return the Int it reduces to if you add and subtract all the numbers, starting at 0. The actual input was much longer and the elements were separated by newlines instead of spaces, but I accounted for that in my function. The sample data returns 3 Method Here’s how I broke down the problem:...

December 2, 2018 · 5 min