Advent of Code 2020 - Day 6

Time to check for some custom declarations forms. In the first part we will check the distinct number of questions anyone on each group answered “yes”, and on the second part the questions where everyone gave a positive response. If you want to follow along please download AdventOfCode2020.pbit and check Day 1 post for instructions. Part 1 The input for this problem is very similar to the passports we have seen on day 4. We have several lines that represent the answers of the persons in a group and the groups are separated by a blank line. ...

January 24, 2021 · 3 min · Pedro Morais

Advent of Code 2020 - Day 5

This problem seems a lot of work at first but in reality it’s just binary number conversion to decimal. Picking up the provided example: FBFBBFF RLR If we replace the lower half [F, L] by 0, and the upper half [B, R] by 1 we get: 0101100 101 Doing the conversions: ...

January 23, 2021 · 3 min · Pedro Morais

Advent of Code 2020 - Day 4

Day 4 is about passport fields validation. In part 1 we need to check if all the fields exist and in part 2 check if they are valid. This seems like a job where the heavy lifting should be made by Power Query. https://adventofcode.com/2020/day/4 If you want to follow along please download AdventOfCode2020.pbit and check Day 1 post for instructions. Part 1 Following this strategy we load the data to our file and we find our first challenge. “Each passport is represented as a sequence of key:value pairs separated by spaces or newlines. Passports are separated by blank lines.” ...

January 22, 2021 · 3 min · Pedro Morais

Advent of Code 2020 - Day 3

Now we need to check for trees in paths. The interesting bit is that the path can grow ad infinitum to the right. Check the details at https://adventofcode.com/2020/day/3 If you want to follow along please download AdventOfCode2020.pbit and check Day 1 post for instructions. Part 1 How do we avoid repeating the pattern? Looking at the provided sample we have: ..##....... #...#...#.. .#....#..#. ..#.#...#.# .#...##..#. ..#.##..... .#.#.#....# .#........# #.##...#... #...##....# .#..#...#.# The interesting part begins after line 3, where we are going to need to get positions that are over the length of the row. The value that we wish for row 4 is 1, which is the value of the remainder of dividing 12 by the lenth of the track which is 11. Adding a new column with the remainder we can crosscheck with our data and everything seems to work: ...

January 20, 2021 · 4 min · Pedro Morais

Advent of Code 2020 - Day 2

We are at an toboggan rental shop and we need to help the shopkeeper to validate a bunch of corrupted passwords. (If you want to follow along please download AdventOfCode2020.pbit and check Day 1 post for instructions) Part 1 In part one we need to check if a given character occurs between a certain lower and upper bound. This kind of operation seems to be more suited to be done in Power Query as we are going row by row checking for the validity of the rule. My idea here is to create a column with value of 1 if the password is valid and 0 otherwise. ...

January 17, 2021 · 2 min · Pedro Morais

Advent of Code 2020 - Day 1

This will be the first post of a series where I hope to be able to solve the problems from the Advent of Code using only Power BI. This event, sadly, only came to my attention this year. It started in 2015 and it’s a lot of fun. In these posts I will talk about my thinking and strategy to try and solve these problems. Without further ado let’s get started: ...

January 16, 2021 · 3 min · Pedro Morais