01020304050607080910111213141516171819202122232425

Advent of Code

2015/25

Let It Snow

in C#

by encse

Merry Christmas! Santa is booting up his weather machine; looks like you might get a white Christmas after all.

The weather machine beeps! On the console of the machine is a copy protection message asking you to enter a code from the instruction manual. Apparently, it refuses to run unless you give it that code. No problem; you'll just look up the code in the--

Read the full puzzle.

using System.Text.RegularExpressions;

namespace AdventOfCode.Y2015.Day25;

[ProblemName("Let It Snow")]
class Solution : Solver {

    public object PartOne(string input) {
        var m = 20151125L;
        var (irow, icol) = (1, 1);
        var (irowDst, icolDst) = Parse(input);
        while (irow != irowDst || icol != icolDst) {
            irow--;
            icol++;
            if (irow == 0) {
                irow = icol;
                icol = 1;
            }
            m = (m * 252533L) % 33554393L;
        }
        return m;
    }

    (int irowDst, int icolDst) Parse(string  input){
        var m = Regex.Match(input, @"To continue, please consult the code grid in the manual.  Enter the code at row (\d+), column (\d+).");
        return (int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
    }
}

Please ☆ my repo if you like it!

© 2025 Advent of Code is a registered trademark in the US Images provided by Bing image creator