--- Day 6: Supplies ---

December 6

Listening to: Christmas lo-fi


Okay, NOW I'm on today's puzzle again. A bit later than intended due to catching up, but I'm here now, with a bit of whiskey, so let's get to the puzzle!


This one seems pretty easy... maybe deceptively easy? I'm not sure. There's a few different ways of dealing with this, but I'm thinking this:

  • Put first four characters in set
  • If set size < 4, continue
  • If set size == 4, start of packet is there
int start = 0;
while(true)
{
    set<char> window;
    for (int i = 0; i < WINDOW_SIZE; i++)
    {
        window.insert(line[start+i]);
    }
    
    if (window.size() == WINDOW_SIZE) break;
    start++;
}

And part two... I just needed to adjust WINDOW_SIZE from 4 to 14. Pretty much no changes, aside from a #define.


Time taken: 15 minutes

My solutions for today's puzzles