From 44709f05494867cfcebb089ddd3e8379acf40484 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 12 Dec 2024 09:30:44 +0000 Subject: [PATCH 1/2] Solve day 12 part 1 Solve part 1 of the puzzle for day 12. --- .../Input/Y2024/Day12/input.txt | 140 ++++++++++++++++++ .../scripts/ts/puzzles/2024/Day12.ts | 2 +- src/AdventOfCode/PathFinding.cs | 24 +-- src/AdventOfCode/Puzzles/Y2024/Day12.cs | 93 ++++++++++-- tests/AdventOfCode.Tests/Api/ApiTests.cs | 2 +- .../Puzzles/Y2024/Day12Tests.cs | 52 +++++-- 6 files changed, 278 insertions(+), 35 deletions(-) create mode 100644 src/AdventOfCode.Resources/Input/Y2024/Day12/input.txt diff --git a/src/AdventOfCode.Resources/Input/Y2024/Day12/input.txt b/src/AdventOfCode.Resources/Input/Y2024/Day12/input.txt new file mode 100644 index 000000000..33cef8ad7 --- /dev/null +++ b/src/AdventOfCode.Resources/Input/Y2024/Day12/input.txt @@ -0,0 +1,140 @@ +MMMMMMMMQMMZZRRXRRRRUUUUUUUUUUUUUUUUEEDEEEEEEEEEEEEEEEEEUUDDDDLLLLLLLLLLLLLJJJJJSSJJCCCCCCCCEEEEEEEEESSSSSSSSSSSSSSWWWWWWWWMMRRRRRRRRRIIIIII +MMMMMMMMMMMMZRRXRRRRUUUUUUUUUUUUUUUUEEEEEEEEEEKKKKKKEEEEUUUUDDDDLLLLLLLLLLLJJJJJJJJJJJCCCCCCEEEEEEEEESBSSSSSSSSSSSSWWWWWWWWMMMRRRRRRRRRIIIII +MMMMMMMMMMMZZRRRRRRRUUUUUUXUXUUUUUUUEEEEEEEEEEEKKKKKKKKGUUUUDDLLLLLLLULLULLJJJJJJJJJJJCCCCEEEEEEEEEESSBBBBSSSSSSSSSWWWWWWPWMMMRRRRRRRRRIIIII +MMMMMMMMMMNRRRERRRRRUUUUXUXUXUUUUUUUUEEEEEEEEEEKKKKKKKKGUUUUUUGLAULLUUUUULLJJJJJJJJJJCCCVC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HHHHHHHHHDDDDHHRRRRRRRROOOORRRWWFFFHHHHICCCCCCCCCVRRRRRJJRRRRVVVVVVVTTVVTVIIIZZZZZZZZ +TTBBBBBBBBBRRRRRRLALLLAAAAGQQQQQQQQQQQQQTTTTTTTTTTTTTTTTHHHHHHHHHDHHHHARRJJRRROOOOORRRFFHHHHHHHHCCCCVVVVVRRRRRRRRRRRRVVVVVVVTVVVVVVVVVVZZZZZ +TBBBBBBBBBRRRRRRRLLLLLAAAAGQQQQQQQQQQQQQTTTTTTTTTTTTTTTHHHHHHHHQHAAAHHAARRRRRRRROORRRRFFFHHHHHHHCCCVVVVVRRRRRRRRRRRRVVVVVVVVVVVVVVVVVVVZZZZZ +TBBBBBBBBBBRRRRRRLLLLLLAAAGGQQQQQQQQQQQQTTTTTTTTTTTTTTTTTHHHHHHHAAAAAAAARAARAARRROFRRFFFFHHHHHHHCWCVVVVVRRRRRRRRRRRRRRVVVVVVVVVVVVVVFVVVVAAA +TTTTBBBBBBBRZRRLLLLLLLLAGGGGGGQQQQQQQQQQTTTTTTTTTTTTTTTTTHHHHPHHAAAAAAAAAAAAAAAARFFFFFFFFFHLHHHHWWCVVVVVRRRRRRRRRRERRRVVVVVVVVVVVVVVVVVVVAAA diff --git a/src/AdventOfCode.Site/scripts/ts/puzzles/2024/Day12.ts b/src/AdventOfCode.Site/scripts/ts/puzzles/2024/Day12.ts index 36f606eb1..2751ea85e 100644 --- a/src/AdventOfCode.Site/scripts/ts/puzzles/2024/Day12.ts +++ b/src/AdventOfCode.Site/scripts/ts/puzzles/2024/Day12.ts @@ -12,7 +12,7 @@ export class Day12 extends Puzzle2024 { } override get name() { - return ''; + return 'Garden Groups'; } override get day() { diff --git a/src/AdventOfCode/PathFinding.cs b/src/AdventOfCode/PathFinding.cs index c7d630532..4b6d570aa 100644 --- a/src/AdventOfCode/PathFinding.cs +++ b/src/AdventOfCode/PathFinding.cs @@ -143,9 +143,9 @@ public static long AStar( /// The starting node. /// The to use. /// - /// An of the visited nodes. + /// An of the visited nodes. /// - public static IReadOnlySet BreadthFirst(IGraph graph, T start, CancellationToken cancellationToken) + public static HashSet BreadthFirst(IGraph graph, T start, CancellationToken cancellationToken) where T : notnull => BreadthFirst(graph.Neighbors, start, cancellationToken); @@ -157,9 +157,9 @@ public static IReadOnlySet BreadthFirst(IGraph graph, T start, Cancella /// The starting node. /// The to use. /// - /// An of the visited nodes. + /// A of the visited nodes. /// - public static IReadOnlySet BreadthFirst( + public static HashSet BreadthFirst( Func> neighbors, T start, CancellationToken cancellationToken) @@ -175,9 +175,9 @@ public static IReadOnlySet BreadthFirst( /// The equality comparer to use between nodes. /// The to use. /// - /// An of the visited nodes. + /// A of the visited nodes. /// - public static IReadOnlySet BreadthFirst( + public static HashSet BreadthFirst( Func> neighbors, T start, IEqualityComparer comparer, @@ -216,9 +216,9 @@ public static IReadOnlySet BreadthFirst( /// The starting node. /// The to use. /// - /// An of the visited nodes. + /// An of the visited nodes. /// - public static IReadOnlySet DepthFirst(IGraph graph, T start, CancellationToken cancellationToken) + public static HashSet DepthFirst(IGraph graph, T start, CancellationToken cancellationToken) where T : notnull => DepthFirst(graph.Neighbors, start, EqualityComparer.Default, cancellationToken); @@ -230,9 +230,9 @@ public static IReadOnlySet DepthFirst(IGraph graph, T start, Cancellati /// The starting node. /// The to use. /// - /// An of the visited nodes. + /// An of the visited nodes. /// - public static IReadOnlySet DepthFirst( + public static HashSet DepthFirst( Func> neighbors, T start, CancellationToken cancellationToken) @@ -248,9 +248,9 @@ public static IReadOnlySet DepthFirst( /// The equality comparer to use between nodes. /// The to use. /// - /// An of the visited nodes. + /// An of the visited nodes. /// - public static IReadOnlySet DepthFirst( + public static HashSet DepthFirst( Func> neighbors, T start, IEqualityComparer comparer, diff --git a/src/AdventOfCode/Puzzles/Y2024/Day12.cs b/src/AdventOfCode/Puzzles/Y2024/Day12.cs index 2dd0b8c43..44cdf148d 100644 --- a/src/AdventOfCode/Puzzles/Y2024/Day12.cs +++ b/src/AdventOfCode/Puzzles/Y2024/Day12.cs @@ -6,18 +6,84 @@ namespace MartinCostello.AdventOfCode.Puzzles.Y2024; /// /// A class representing the puzzle for https://adventofcode.com/2024/day/12. This class cannot be inherited. /// -[Puzzle(2024, 12, "", RequiresData = true, IsHidden = true)] +[Puzzle(2024, 12, "Garden Groups", RequiresData = true)] public sealed class Day12 : Puzzle { -#pragma warning disable IDE0022 -#pragma warning disable IDE0060 -#pragma warning disable SA1600 + /// + /// Gets the total price for the fencing. + /// + public int TotalPrice { get; private set; } - public int Solution { get; private set; } - - public static int Solve(IList values) + /// + /// Computes the price of adding fencing to separate the regions of the specified map. + /// + /// The map to compute the fencing price for. + /// The to use. + /// + /// The total price for the fencing. + /// + public static int Compute(IList map, CancellationToken cancellationToken) { - return -1; + var bounds = new Rectangle(0, 0, map[0].Length, map.Count); + var regions = new List>(); + var unexplored = new HashSet(); + + for (int y = 0; y < map.Count; y++) + { + for (int x = 0; x < map[y].Length; x++) + { + unexplored.Add(new(x, y)); + } + } + + while (unexplored.Count > 0 && !cancellationToken.IsCancellationRequested) + { + var origin = unexplored.First(); + char plant = map[origin.Y][origin.X]; + + var garden = new Garden(plant, map, bounds); + + var region = PathFinding.BreadthFirst(garden, origin, cancellationToken); + regions.Add(region); + + unexplored.ExceptWith(region); + } + + cancellationToken.ThrowIfCancellationRequested(); + + int price = 0; + + foreach (var region in regions) + { + int perimeter = 0; + + foreach (var point in region) + { + if (!region.Contains(new(point.X, point.Y - 1))) + { + perimeter++; + } + + if (!region.Contains(new(point.X, point.Y + 1))!) + { + perimeter++; + } + + if (!region.Contains(new(point.X - 1, point.Y))) + { + perimeter++; + } + + if (!region.Contains(new(point.X + 1, point.Y))) + { + perimeter++; + } + } + + price += region.Count * perimeter; + } + + return price; } /// @@ -27,13 +93,18 @@ protected override async Task SolveCoreAsync(string[] args, Cancel var values = await ReadResourceAsLinesAsync(cancellationToken); - Solution = Solve(values); + TotalPrice = Compute(values, cancellationToken); if (Verbose) { - Logger.WriteLine("{0}", Solution); + Logger.WriteLine("The total price of fencing all regions of the map is {0}.", TotalPrice); } - return PuzzleResult.Create(Solution); + return PuzzleResult.Create(TotalPrice); + } + + private sealed class Garden(char plant, IList plants, Rectangle bounds) : SquareGrid(bounds) + { + public override bool IsPassable(Point id) => plants[id.Y][id.X] == plant; } } diff --git a/tests/AdventOfCode.Tests/Api/ApiTests.cs b/tests/AdventOfCode.Tests/Api/ApiTests.cs index 083cf188c..7f5b3b12c 100644 --- a/tests/AdventOfCode.Tests/Api/ApiTests.cs +++ b/tests/AdventOfCode.Tests/Api/ApiTests.cs @@ -216,7 +216,7 @@ public class ApiTests(HttpServerFixture fixture, ITestOutputHelper outputHelper) [PuzzleData(2024, 09, -1, Skip = "Not implemented.")] [PuzzleData(2024, 10, 778, 1925)] [PuzzleData(2024, 11, 220722, 261952051690787)] - [PuzzleData(2024, 12, -1, Skip = "Not implemented.")] + [PuzzleData(2024, 12, 1465112)] [PuzzleData(2024, 13, -1, Skip = "Not implemented.")] [PuzzleData(2024, 14, -1, Skip = "Not implemented.")] [PuzzleData(2024, 15, -1, Skip = "Not implemented.")] diff --git a/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs b/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs index a381018fb..0552c9777 100644 --- a/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs +++ b/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs @@ -5,23 +5,55 @@ namespace MartinCostello.AdventOfCode.Puzzles.Y2024; public sealed class Day12Tests(ITestOutputHelper outputHelper) : PuzzleTest(outputHelper) { - [Fact(Skip = "Not implemented.")] - public void Y2024_Day12_Solve_Returns_Correct_Value() + public static TheoryData Examples() + { + return new() + { + { + new[] + { + "OOOOO", + "OXOXO", + "OOOOO", + "OXOXO", + "OOOOO", + }, + 772 + }, + { + new[] + { + "RRRRIICCFF", + "RRRRIICCCF", + "VVRRRCCFFF", + "VVRCCCJFFF", + "VVVVCJJCFE", + "VVIVCCJJEE", + "VVIIICJJEE", + "MIIIIIJJEE", + "MIIISIJEEE", + "MMMISSJEEE", + }, + 1930 + }, + }; + } + + [Theory] + [MemberData(nameof(Examples))] + public void Y2024_Day12_Compute_Returns_Correct_Value(string[] values, int expected) { // Arrange - string[] values = - [ - "_", - ]; + using var cts = Timeout(); // Act - int actual = Day12.Solve(values); + int actual = Day12.Compute(values, cts.Token); // Assert - actual.ShouldBe(-1); + actual.ShouldBe(expected); } - [Fact(Skip = "Not implemented.")] + [Fact] public async Task Y2024_Day12_Solve_Returns_Correct_Solution() { // Act @@ -29,6 +61,6 @@ public async Task Y2024_Day12_Solve_Returns_Correct_Solution() // Assert puzzle.ShouldNotBeNull(); - puzzle.Solution.ShouldBe(-1); + puzzle.TotalPrice.ShouldBe(1465112); } } From 5a2c37eb14935e7c2175039d57e71769a151bd49 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 13 Dec 2024 08:19:04 +0000 Subject: [PATCH 2/2] Skeleton of solution for day 12 Add skeleton for implementing part 2 for day 12 of 2024. --- src/AdventOfCode/Puzzles/Y2024/Day12.cs | 57 +++++++++++-------- .../Puzzles/Y2024/Day12Tests.cs | 47 +++++++++++++-- 2 files changed, 77 insertions(+), 27 deletions(-) diff --git a/src/AdventOfCode/Puzzles/Y2024/Day12.cs b/src/AdventOfCode/Puzzles/Y2024/Day12.cs index 44cdf148d..1a300d81f 100644 --- a/src/AdventOfCode/Puzzles/Y2024/Day12.cs +++ b/src/AdventOfCode/Puzzles/Y2024/Day12.cs @@ -10,19 +10,25 @@ namespace MartinCostello.AdventOfCode.Puzzles.Y2024; public sealed class Day12 : Puzzle { /// - /// Gets the total price for the fencing. + /// Gets the total price for the fencing without a bulk discount. /// - public int TotalPrice { get; private set; } + public int TotalPriceWithoutDiscount { get; private set; } + + /// + /// Gets the total price for the fencing with a bulk discount. + /// + public int TotalPriceWithDiscount { get; private set; } /// /// Computes the price of adding fencing to separate the regions of the specified map. /// /// The map to compute the fencing price for. + /// Whether to compute the price for a bulk discount. /// The to use. /// /// The total price for the fencing. /// - public static int Compute(IList map, CancellationToken cancellationToken) + public static int Compute(IList map, bool bulkDiscount, CancellationToken cancellationToken) { var bounds = new Rectangle(0, 0, map[0].Length, map.Count); var regions = new List>(); @@ -54,36 +60,39 @@ public static int Compute(IList map, CancellationToken cancellationToken int price = 0; foreach (var region in regions) + { + int factor = bulkDiscount ? Sides(region) : Perimeter(region); + price += region.Count * factor; + } + + return price; + + static int Perimeter(HashSet region) { int perimeter = 0; foreach (var point in region) { - if (!region.Contains(new(point.X, point.Y - 1))) - { - perimeter++; - } - - if (!region.Contains(new(point.X, point.Y + 1))!) - { - perimeter++; - } + var direction = new Size(0, 1); - if (!region.Contains(new(point.X - 1, point.Y))) + for (int i = 0; i < 4; i++) { - perimeter++; - } + if (!region.Contains(point + direction)) + { + perimeter++; + } - if (!region.Contains(new(point.X + 1, point.Y))) - { - perimeter++; + direction = Right(direction); } } - price += region.Count * perimeter; + return perimeter; } - return price; + static int Sides(HashSet region) + => Perimeter(region); // TODO Walk all the borders of the region and count the number of turns + + static Size Right(Size direction) => new(-direction.Height, direction.Width); } /// @@ -93,14 +102,16 @@ protected override async Task SolveCoreAsync(string[] args, Cancel var values = await ReadResourceAsLinesAsync(cancellationToken); - TotalPrice = Compute(values, cancellationToken); + TotalPriceWithoutDiscount = Compute(values, bulkDiscount: false, cancellationToken); + TotalPriceWithDiscount = Compute(values, bulkDiscount: true, cancellationToken); if (Verbose) { - Logger.WriteLine("The total price of fencing all regions of the map is {0}.", TotalPrice); + Logger.WriteLine("The total price of fencing all regions of the map is {0} with no discount.", TotalPriceWithoutDiscount); + Logger.WriteLine("The total price of fencing all regions of the map is {0} with a bulk discount.", TotalPriceWithDiscount); } - return PuzzleResult.Create(TotalPrice); + return PuzzleResult.Create(TotalPriceWithoutDiscount, TotalPriceWithDiscount); } private sealed class Garden(char plant, IList plants, Rectangle bounds) : SquareGrid(bounds) diff --git a/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs b/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs index 0552c9777..bfa663892 100644 --- a/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs +++ b/tests/AdventOfCode.Tests/Puzzles/Y2024/Day12Tests.cs @@ -5,7 +5,7 @@ namespace MartinCostello.AdventOfCode.Puzzles.Y2024; public sealed class Day12Tests(ITestOutputHelper outputHelper) : PuzzleTest(outputHelper) { - public static TheoryData Examples() + public static TheoryData Examples() { return new() { @@ -18,6 +18,7 @@ public static TheoryData Examples() "OXOXO", "OOOOO", }, + false, 772 }, { @@ -34,20 +35,57 @@ public static TheoryData Examples() "MIIISIJEEE", "MMMISSJEEE", }, + false, 1930 }, + { + new[] + { + "AAAA", + "BBCD", + "BBCC", + "EEEC", + }, + true, + 80 + }, + { + new[] + { + "EEEEE", + "EXXXX", + "EEEEE", + "EXXXX", + "EEEEE", + }, + true, + 236 + }, + { + new[] + { + "AAAAAA", + "AAABBA", + "AAABBA", + "ABBAAA", + "ABBAAA", + "AAAAAA", + }, + true, + 368 + }, }; } [Theory] [MemberData(nameof(Examples))] - public void Y2024_Day12_Compute_Returns_Correct_Value(string[] values, int expected) + public void Y2024_Day12_Compute_Returns_Correct_Value(string[] values, bool bulkDiscount, int expected) { // Arrange using var cts = Timeout(); // Act - int actual = Day12.Compute(values, cts.Token); + int actual = Day12.Compute(values, bulkDiscount, cts.Token); // Assert actual.ShouldBe(expected); @@ -61,6 +99,7 @@ public async Task Y2024_Day12_Solve_Returns_Correct_Solution() // Assert puzzle.ShouldNotBeNull(); - puzzle.TotalPrice.ShouldBe(1465112); + puzzle.TotalPriceWithoutDiscount.ShouldBe(1465112); + puzzle.TotalPriceWithDiscount.ShouldBe(-1); } }