Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
encse committed Dec 24, 2024
1 parent b8b2c70 commit 179666b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions 2024/Day23/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ namespace AdventOfCode.Y2024.Day23;
class Solution : Solver {
public object PartOne(string input) {
var g = GetGraph(input);
var components = GetSeed(g);
var components = g.Keys.ToHashSet();
components = Grow(g, components);
components = Grow(g, components);
return components.Count(c => Members(c).Any(m=>m.StartsWith("t")));
return components.Count(c => Members(c).Any(m => m.StartsWith("t")));
}

public object PartTwo(string input) {
var g = GetGraph(input);
var components = GetSeed(g);
var components = g.Keys.ToHashSet();
while (components.Count > 1) {
components = Grow(g, components);
}
return components.Single();
}

HashSet<Component> GetSeed(Graph g) => g.Keys.ToHashSet();

HashSet<Component> Grow(Graph g, HashSet<Component> components) => (
from c in components.AsParallel()
Expand Down

0 comments on commit 179666b

Please sign in to comment.