From 4acdf43eb1f557239566185a6c211a198d6d7520 Mon Sep 17 00:00:00 2001 From: Amatsugu Date: Sun, 14 Dec 2025 15:43:09 -0500 Subject: [PATCH] day 8 wip --- .../Problems/AOC2025/Day8/Playground.cs | 65 +++++++++++++++++++ AdventOfCode/Program.cs | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 AdventOfCode/Problems/AOC2025/Day8/Playground.cs diff --git a/AdventOfCode/Problems/AOC2025/Day8/Playground.cs b/AdventOfCode/Problems/AOC2025/Day8/Playground.cs new file mode 100644 index 0000000..2cd0246 --- /dev/null +++ b/AdventOfCode/Problems/AOC2025/Day8/Playground.cs @@ -0,0 +1,65 @@ +using AdventOfCode.Utils.Models; + +using System; +using System.Collections.Generic; +using System.Text; + +namespace AdventOfCode.Problems.AOC2025.Day8; + +[ProblemInfo(2025, 8, "Playground")] +internal class Playground : Problem +{ + private Vec3[] _boxPositions= []; + + public override void CalculatePart1() + { + var boxes = _boxPositions.Select((p, i) => new JunctionBox(i, p, [])); + var closest = GetClosestPairs(_boxPositions, 10); + foreach (var (a, b)in closest) + { + var boxA = boxes.First(box => box.Pos == a); + var boxB = boxes.First(box => box.Pos == b); + boxA.Connections.Add(boxB.Id); + boxB.Connections.Add(boxA.Id); + } + + } + + private static long[] TraceNetworks(JunctionBox[] junctionBoxes) + { + return []; + } + + private static List<(Vec3 a , Vec3 b)> GetClosestPairs(Vec3[] boxes, int count = 10) + { + var distances = new Dictionary<(Vec3 a, Vec3 b), double>(); + + for (int i = 0; i < boxes.Length; i++) + { + var a = boxes[i]; + for (int j = (i + 1); j < boxes.Length; j++) + { + var b = boxes[j]; + if (distances.ContainsKey((a, b)) || distances.ContainsKey((b, a))) + continue; + distances.Add((a, b), Math.Sqrt(a.DistanceSq(b))); + } + } + return distances.OrderBy(v => v.Value).Take(count).Select(v => v.Key).ToList(); + } + + public override void CalculatePart2() + { + throw new NotImplementedException(); + } + + public override void LoadInput() + { + _boxPositions = ReadInputLines("sample.txt") + .Select(l => l.Split(',').Select(int.Parse)) + .Select(c => new Vec3(c.First(), c.Skip(1).First(), c.Last())) + .ToArray(); + } + + private record JunctionBox(int Id, Vec3 Pos, HashSet Connections); +} diff --git a/AdventOfCode/Program.cs b/AdventOfCode/Program.cs index 29d0831..125614e 100644 --- a/AdventOfCode/Program.cs +++ b/AdventOfCode/Program.cs @@ -4,4 +4,4 @@ global using AdventOfCode.Utils; var runner = new AOCRunner(); -runner.WithDay(7).RenderInteractiveMenu(); +runner.WithDay(8).RenderInteractiveMenu();