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 3a50e0d commit ebf2a38
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 47 deletions.
6 changes: 6 additions & 0 deletions 2024/Day25/README.md
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._
24 changes: 24 additions & 0 deletions 2024/Day25/Solution.cs
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 added 2024/Day25/input.in
Binary file not shown.
1 change: 1 addition & 0 deletions 2024/Day25/input.refout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3242
64 changes: 32 additions & 32 deletions 2024/SplashScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public void Show() {

var color = Console.ForegroundColor;
Write(0xcc00, false, " ▄█▄ ▄▄█ ▄ ▄ ▄▄▄ ▄▄ ▄█▄ ▄▄▄ ▄█ ▄▄ ▄▄▄ ▄▄█ ▄▄▄\n █▄█ █ █ █ █ █▄█ █ █ █ █ █ █▄ ");
Write(0xcc00, false, " █ █ █ █ █ █▄█\n █ █ █▄█ ▀▄▀ █▄▄ █ █ █▄ █▄█ █ █▄ █▄█ █▄█ █▄▄ int y = 2024;\n ");
Write(0xcc00, false, " \n ");
Write(0xcc00, false, " █ █ █ █ █ █▄█\n █ █ █▄█ ▀▄▀ █▄▄ █ █ █▄ █▄█ █ █▄ █▄█ █▄█ █▄▄ $year = 2024\n ");
Write(0xcc00, false, "\n ");
Write(0x888888, false, " .-----. .------------------. \n ");
Write(0xcccccc, false, ".--'");
Write(0xe3b585, false, "~ ~ ~");
Expand Down Expand Up @@ -51,7 +51,7 @@ public void Show() {
Write(0xcccccc, false, "|");
Write(0x427322, false, "#");
Write(0x5eabb4, false, "..");
Write(0x1461f, false, "#");
Write(0x427322, false, "@");
Write(0xe3b585, false, "'. ~ ");
Write(0xcc00, false, "\" ' ");
Write(0xe3b585, false, "~ ");
Expand All @@ -68,9 +68,9 @@ public void Show() {
Write(0xcccccc, false, "| 4 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0x427322, false, "_");
Write(0x488813, false, "_");
Write(0x5eabb4, false, ".~.");
Write(0x7fbd39, false, "_");
Write(0x4d8b03, false, "_");
Write(0x488813, false, "@");
Write(0xe3b585, false, "'.. ~ ~ ");
Write(0xffff66, true, "*");
Expand All @@ -84,10 +84,10 @@ public void Show() {
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "| ");
Write(0xffffff, false, "||| ");
Write(0x7fbd39, false, "@");
Write(0x427322, false, "@");
Write(0x488813, false, "@");
Write(0x488813, false, "#");
Write(0x4d8b03, false, "@");
Write(0x427322, false, "@");
Write(0x1461f, false, "@");
Write(0xe3b585, false, "'''...");
Write(0xcccccc, false, "| |");
Write(0xa25151, false, "... ");
Expand All @@ -98,13 +98,12 @@ public void Show() {
Write(0xcccccc, false, "| 6 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0x1461f, false, "@");
Write(0xffffff, false, "~~~");
Write(0x7fbd39, false, "@");
Write(0x488813, false, "#");
Write(0x427322, false, "# @ ");
Write(0x4d8b03, false, "@@");
Write(0x1461f, false, "@ ");
Write(0xffffff, false, "~~~");
Write(0x7fbd39, false, "#@");
Write(0x488813, false, "@ @ ");
Write(0x7fbd39, false, "# ");
Write(0x427322, false, "@ ");
Write(0xcccccc, false, "| |");
Write(0xa5a8af, false, "/\\ ");
Write(0xa25151, false, "''. ");
Expand Down Expand Up @@ -159,8 +158,7 @@ public void Show() {
Write(0xcccccc, false, "| |");
Write(0xa5a8af, false, "/\\ ");
Write(0xa25151, false, "..' ");
Write(0xcccccc, false, "| |");
Write(0xb5ed, false, ". ");
Write(0xcccccc, false, "| | ");
Write(0xffffff, false, ". ");
Write(0xcccccc, false, "| 11 ");
Write(0xffff66, false, "**\n ");
Expand All @@ -172,18 +170,17 @@ public void Show() {
Write(0xffff66, true, ":");
Write(0x333333, false, "::");
Write(0xcccccc, false, "| | ");
Write(0xffffff, false, ". ");
Write(0xa2db, false, "'");
Write(0xffffff, false, ". ");
Write(0xcccccc, false, "| 12 ");
Write(0xffff66, false, "**\n ");
Write(0xcccccc, false, "|");
Write(0xffffff, false, "'. - -");
Write(0xcccccc, false, "| | ");
Write(0x333333, false, ". ::");
Write(0xcccccc, false, "| | ");
Write(0x333333, false, "::");
Write(0x9900, true, ":");
Write(0x333333, false, "::");
Write(0xcccccc, false, "| |");
Write(0x91cc, false, ". ");
Write(0x91cc, false, "~ ");
Write(0xffffff, false, ".' ");
Write(0xcccccc, false, "| 13 ");
Write(0xffff66, false, "**\n ");
Expand Down Expand Up @@ -218,7 +215,8 @@ public void Show() {
Write(0x5555bb, false, "~ ");
Write(0xcc00, false, "'.");
Write(0xcccccc, false, "| |");
Write(0x666666, false, " : ");
Write(0x333333, false, ".");
Write(0x666666, false, ": ");
Write(0x333333, false, "::");
Write(0x553322, true, ":");
Write(0x333333, false, "::");
Expand All @@ -242,8 +240,7 @@ public void Show() {
Write(0xcc00, false, "'..' .'");
Write(0xcccccc, false, "| |");
Write(0x666666, false, " '");
Write(0x456efe, true, "o");
Write(0x333333, false, ". .");
Write(0x456efe, true, "o ");
Write(0xcccccc, false, "| |");
Write(0x666666, false, "┘");
Write(0xffff66, true, "*");
Expand All @@ -254,7 +251,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, "─┘├┬┬┬┴─");
Write(0xcccccc, false, "| 19 ");
Expand All @@ -276,8 +274,9 @@ public void Show() {
Write(0x66ff, false, ".-");
Write(0xcccccc, false, "((");
Write(0x66ff, false, "---.");
Write(0xcccccc, false, "'------. |");
Write(0x666666, false, " :");
Write(0xcccccc, false, "'------. | ");
Write(0x333333, false, ".");
Write(0x666666, false, ":");
Write(0xff0000, false, "|");
Write(0xcccccc, false, "\\| ");
Write(0x333399, false, "~ ");
Expand All @@ -295,9 +294,7 @@ public void Show() {
Write(0xff0000, false, ".---_ ");
Write(0x66ff, false, "'------'_ ");
Write(0xaaaaaa, false, ".~' ");
Write(0xcccccc, false, "| | ");
Write(0x333333, false, ".");
Write(0xcccccc, false, "|");
Write(0xcccccc, false, "| | |");
Write(0xff0000, false, "\\|");
Write(0x9900ff, false, "\\ / \\ /");
Write(0x333399, false, "~ ");
Expand Down Expand Up @@ -345,8 +342,11 @@ public void Show() {
Write(0xaaaaaa, false, "_ ");
Write(0xcccccc, false, "| 24 ");
Write(0xffff66, false, "**\n ");
Write(0x333333, false, "| | '-. .-' ");
Write(0x666666, false, "25\n \n");
Write(0x666666, false, "|/ \\ \\ '------'/ / \\ \\| '-.! /^\\ / \\.~~./ \\.-' ");
Write(0xcccccc, false, "25 ");
Write(0xffff66, false, "*");
Write(0x666666, false, "*\n ");
Write(0x888888, false, "'----------------------' '------------------' \n \n");

Console.ForegroundColor = color;
Console.WriteLine();
Expand Down
Loading

0 comments on commit ebf2a38

Please sign in to comment.