Advent of Code: Day 6 Solution

This year, I’m posting my solutions to the puzzles in the Advent of Code. Each post will consist of pseudocode, with a link to the actual code I used to solve the puzzle on Github.

And now, on with the solution:

Day 6, part 1

Simplified problem: Given a list of inputs, calculate the most frequent characters in each column


  1. Set input=(input)
  2. Set numColumns to input character’s length
  3. Set message=nothing
  4. For i=1 to numColumns (loop through columns)
  5. For each line in input
    1. Set columInput=nothing
    2. For each line in input
      1. Append the first character of line to columnInput
    3. End For
    4. Set distinctCharacters = distinct characters in columnInput
    5. Sort distinctCharacters in descending order
    6. Add the first character in distinctCharacters to message
  6. End For
  7. Return message

Day 6, part 2

Perform the same task, but calculate the least frequent characters in each column.


  • Perform the same steps as in Day 6, part 1, however in step 5.6 add the last character in distinctCharacters to message

You can find the full solution on Github

Leave a Reply

Your email address will not be published. Required fields are marked *