--- Day 1: Feeling Safe ---

December 1

Listening to: Vinesauce (talking about the weather)


Another year, and honestly... this might be a pretty minimal blog this year. The last few years I've treated this as a stream-of-consciousness thing, but I'm not using it to learn anything new, just iterate on what I did last year.

int position = 50, zeros, passes;

foreach (string rotation in rotations)
{
    int distance = int.Parse(rotation.Substring(1));

    if (rotation[0] == 'R')
    {
        for (int i = 0; i < distance; i++)
        {
            position++;
            if (position == 100) { position = 0; passes++; }
        }
    }
    else
    {
        for (int i = 0; i < distance; i++)
        {
            position--;
            if (position == 0) passes++;
            else if (position == -1) position = 99;
        }
    }

    if (position == 0) zeros++;
}

It just made sense to combine both the "stops at zero" and "passes zero" into one pass. I wish I could have done it more elegantly than doing each click of the dial individually, but ah well.


Time taken: 20 minutes

My solutions for today's puzzles