010203040506070809101112

Advent of Code

2025/12

Christmas Tree Farm

in C#

by encse

You're almost out of time, but there can't be much left to decorate. Although there are no stairs, elevators, escalators, tunnels, chutes, teleporters, firepoles, or conduits here that would take you deeper into the North Pole base, there is a ventilation duct. You jump in.

After bumping around for a few minutes, you emerge into a large, well-lit cavern full of Christmas trees!

Visit the website for the full story and full puzzle description.

I have no words for this...

namespace AdventOfCode.Y2025.Day12;

using System;
using System.Linq;
using System.Text.RegularExpressions;

[ProblemName("Christmas Tree Farm")]
class Solution : Solver {

    public object PartOne(string input) {
        // It's enough to check if the 3x3 area of the presents is less than 
        // the area under 🎄 tree. No packing required.
        return input.Split("\n\n").Last()
            .Split("\n")
            .Select(line => Regex.Matches(line, @"\d+").Select(m => int.Parse(m.Value)).ToArray())
            .Count(nums => nums[0] * nums[1] >= 9 * nums[2..].Sum());
    }
}

Please ☆ my repo if you like it!

© 2025 | Advent of Code is a registered trademark in the US | Images provided by Bing and Nano Banana