Skip to content

Commit

Permalink
2024/19
Browse files Browse the repository at this point in the history
  • Loading branch information
encse committed Dec 19, 2024
1 parent 1f1f732 commit 2c8ae94
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions 2024/Day19/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ long MatchCount(string[] towels, string pattern, Cache cache) =>
cache.GetOrAdd(pattern, (pattern) =>
pattern switch {
"" => 1,
_ => (
from towel in towels
where pattern.StartsWith(towel)
select MatchCount(towels, pattern[towel.Length..], cache)
).Sum()
_ => towels
.Where(pattern.StartsWith)
.Sum(towel => MatchCount(towels, pattern[towel.Length ..], cache))
}
);
}

0 comments on commit 2c8ae94

Please sign in to comment.