-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## --- Day 25: Code Chronicle --- | ||
Out of ideas and time, The Historians agree that they should go back to check the <em>Chief Historian's office</em> one last time, just in case he went back there without you noticing. | ||
|
||
When you get there, you are surprised to discover that the door to his office is <em>locked</em>! You can hear someone inside, but knocking yields no response. The locks on this floor are all fancy, expensive, virtual versions of [five-pin tumbler locks](https://en.wikipedia.org/wiki/Pin_tumbler_lock), so you contact North Pole security to see if they can help open the door. | ||
|
||
_Visit the website for the full story and [full puzzle](https://adventofcode.com/2024/day/25) description._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace AdventOfCode.Y2024.Day25; | ||
|
||
using System; | ||
using System.Linq; | ||
|
||
[ProblemName("Code Chronicle")] | ||
class Solution : Solver { | ||
|
||
public object PartOne(string input) { | ||
int[] parsePattern(string[] lines) => | ||
Enumerable.Range(0, lines[0].Length).Select(x => | ||
Enumerable.Range(0, lines.Length).Count(y => lines[y][x] == '#') | ||
).ToArray(); | ||
|
||
bool match(int[] k, int[] l) => | ||
Enumerable.Range(0, k.Length).All(i => k[i] + l[i] <= 7); | ||
|
||
var patterns = input.Split("\n\n").Select(b=>b.Split("\n")); | ||
var keys = patterns.Where(p => p[0][0] == '.').Select(parsePattern).ToList(); | ||
var locks = patterns.Where(p => p[0][0] == '#').Select(parsePattern).ToList(); | ||
|
||
return keys.Sum(k => locks.Count(l => match(l,k))); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3242 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.