Skip to content

Commit

Permalink
2024/25
Browse files Browse the repository at this point in the history
  • Loading branch information
encse committed Dec 25, 2024
1 parent d1bd1cf commit 5cab3c2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 52 deletions.
2 changes: 0 additions & 2 deletions 2024/Day25/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ Out of ideas and time, The Historians agree that they should go back to check th
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._

A simple one for the last day to ease out. I used some linq as usual.
12 changes: 6 additions & 6 deletions 2024/Day25/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ namespace AdventOfCode.Y2024.Day25;
class Solution : Solver {

public object PartOne(string input) {
int[] parsePattern(string[] lines) =>
Enumerable.Range(0, lines[0].Length).Select(x =>
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) =>

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 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)));
return keys.Sum(k => locks.Count(l => match(l, k)));
}
}
73 changes: 44 additions & 29 deletions 2024/SplashScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Show() {
Write(0xcccccc, false, "| 3 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0x427322, false, "#");
Write(0x488813, false, "@");
Write(0x5eabb4, false, "..");
Write(0x427322, false, "@");
Write(0xe3b585, false, "'. ~ ");
Expand All @@ -68,10 +68,10 @@ public void Show() {
Write(0xcccccc, false, "| 4 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0x488813, false, "_");
Write(0x5eabb4, false, ".~.");
Write(0x4d8b03, false, "_");
Write(0x488813, false, "@");
Write(0x5eabb4, false, ".~.");
Write(0x1461f, false, "_");
Write(0x4d8b03, false, "@");
Write(0xe3b585, false, "'.. ~ ~ ");
Write(0xffff66, true, "*");
Write(0xcccccc, false, "| | ");
Expand All @@ -84,10 +84,9 @@ public void Show() {
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "| ");
Write(0xffffff, false, "||| ");
Write(0x488813, false, "#");
Write(0x4d8b03, false, "@");
Write(0x427322, false, "@");
Write(0x1461f, false, "@");
Write(0x7fbd39, false, "#");
Write(0x427322, false, "@@");
Write(0x488813, false, "@");
Write(0xe3b585, false, "'''...");
Write(0xcccccc, false, "| |");
Write(0xa25151, false, "... ");
Expand All @@ -98,12 +97,16 @@ public void Show() {
Write(0xcccccc, false, "| 6 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0x488813, false, "#");
Write(0x427322, false, "@");
Write(0xffffff, false, "~~~");
Write(0x7fbd39, false, "#@");
Write(0x488813, false, "@ @ ");
Write(0x7fbd39, false, "# ");
Write(0x427322, false, "@ ");
Write(0x7fbd39, false, "@");
Write(0x427322, false, "#");
Write(0x488813, false, "@");
Write(0x427322, false, "@");
Write(0x7fbd39, false, "#");
Write(0x1461f, false, "@ ");
Write(0x4d8b03, false, "# ");
Write(0x7fbd39, false, "@");
Write(0xcccccc, false, "| |");
Write(0xa5a8af, false, "/\\ ");
Write(0xa25151, false, "''. ");
Expand Down Expand Up @@ -158,7 +161,8 @@ public void Show() {
Write(0xcccccc, false, "| |");
Write(0xa5a8af, false, "/\\ ");
Write(0xa25151, false, "..' ");
Write(0xcccccc, false, "| | ");
Write(0xcccccc, false, "| | ");
Write(0xb5ed, false, "' ");
Write(0xffffff, false, ". ");
Write(0xcccccc, false, "| 11 ");
Write(0xffff66, false, "**\n ");
Expand All @@ -170,7 +174,8 @@ public void Show() {
Write(0xffff66, true, ":");
Write(0x333333, false, "::");
Write(0xcccccc, false, "| | ");
Write(0xffffff, false, ". ");
Write(0xffffff, false, ". ");
Write(0x9933, true, ".");
Write(0xcccccc, false, "| 12 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Expand All @@ -180,16 +185,17 @@ public void Show() {
Write(0x9900, true, ":");
Write(0x333333, false, "::");
Write(0xcccccc, false, "| |");
Write(0x91cc, false, "~ ");
Write(0xffffff, false, ".' ");
Write(0xff9900, true, ". ");
Write(0xffffff, false, ".' ");
Write(0x9933, true, ". ");
Write(0xcccccc, false, "| 13 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0xcc00, false, "...");
Write(0xffffff, false, "'..''");
Write(0xcccccc, false, "| |");
Write(0xffffff, true, ". ");
Write(0x333333, false, ":");
Write(0xffffff, true, ". ");
Write(0x333333, false, ".:");
Write(0x9900, true, ":::");
Write(0x333333, false, ":");
Write(0xcccccc, false, "| |");
Expand Down Expand Up @@ -231,7 +237,8 @@ public void Show() {
Write(0x5555bb, false, "~ ");
Write(0xcc00, false, ":");
Write(0xcccccc, false, "| |");
Write(0x666666, false, " '. ");
Write(0x666666, false, " '.");
Write(0x333333, false, ". ");
Write(0xcccccc, false, "| |");
Write(0x666666, false, "┬o┤ten├─");
Write(0xcccccc, false, "| 17 ");
Expand All @@ -251,8 +258,7 @@ public void Show() {
Write(0x5555bb, false, "~ ");
Write(0xcc00, false, "..' ");
Write(0xcccccc, false, "| |");
Write(0x666666, false, ": '. ");
Write(0x333333, false, ".");
Write(0x666666, false, ": '. ");
Write(0xcccccc, false, "| |");
Write(0x666666, false, "─┘├┬┬┬┴─");
Write(0xcccccc, false, "| 19 ");
Expand All @@ -274,9 +280,8 @@ public void Show() {
Write(0x66ff, false, ".-");
Write(0xcccccc, false, "((");
Write(0x66ff, false, "---.");
Write(0xcccccc, false, "'------. | ");
Write(0x333333, false, ".");
Write(0x666666, false, ":");
Write(0xcccccc, false, "'------. |");
Write(0x666666, false, " :");
Write(0xff0000, false, "|");
Write(0xcccccc, false, "\\| ");
Write(0x333399, false, "~ ");
Expand Down Expand Up @@ -342,10 +347,20 @@ public void Show() {
Write(0xaaaaaa, false, "_ ");
Write(0xcccccc, false, "| 24 ");
Write(0xffff66, false, "**\n ");
Write(0x666666, false, "|/ \\ \\ '------'/ / \\ \\| '-.! /^\\ / \\.~~./ \\.-' ");
Write(0xcccccc, false, "25 ");
Write(0xffff66, false, "*");
Write(0x666666, false, "*\n ");
Write(0xcccccc, false, "|");
Write(0x880000, false, "/ \\ ");
Write(0xff0000, false, "\\ ");
Write(0x66ff, false, "'------'");
Write(0xaaaaaa, false, "/ ");
Write(0xe6410b, false, "/ \\ ");
Write(0xaaaaaa, false, "\\");
Write(0xcccccc, false, "| '-.");
Write(0x9b715b, false, "! /^\\ ");
Write(0xaaaaaa, false, "/ \\");
Write(0x5eabb4, false, ".~~.");
Write(0xaaaaaa, false, "/ \\");
Write(0xcccccc, false, ".-' 25 ");
Write(0xffff66, false, "**\n ");
Write(0x888888, false, "'----------------------' '------------------' \n \n");

Console.ForegroundColor = color;
Expand Down
Loading

0 comments on commit 5cab3c2

Please sign in to comment.