Skip to content

Commit a8cacf8

Browse files
committed
2025/06
1 parent e59a02f commit a8cacf8

6 files changed

Lines changed: 122 additions & 28 deletions

File tree

2025/Day06/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## --- Day 6: Trash Compactor ---
2+
After helping the Elves in the kitchen, you were taking a break and helping them re-enact a movie scene when you over-enthusiastically jumped into the garbage chute!
3+
4+
A brief fall later, you find yourself in a garbage smasher. Unfortunately, the door's been magnetically sealed.
5+
6+
_Visit the website for the full story and [full puzzle](https://adventofcode.com/2025/day/6) description._

2025/Day06/Solution.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
namespace AdventOfCode.Y2025.Day06;
2+
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
6+
record Problem(char op, IEnumerable<long> nums);
7+
8+
[ProblemName("Trash Compactor")]
9+
class Solution : Solver {
10+
11+
// Split the input to separate blocks first, then parse them row by row
12+
// in part one. We can deal with part two by applying Transpose to the blocks
13+
// first. The operator moves from the bottom-left corner to the top-right:
14+
15+
// "15" "1 +"
16+
// " 5" becomes "55 "
17+
// "+ "
18+
19+
public object PartOne(string input) => Solve(
20+
from rows in ParseBlocks(input)
21+
select new Problem(
22+
rows.Last()[0],
23+
rows[..^1].Select(long.Parse)
24+
)
25+
);
26+
public object PartTwo(string input) => Solve(
27+
from cols in ParseBlocks(input).Select(Transpose)
28+
select new Problem(
29+
cols.First()[^1],
30+
cols.Select(col => long.Parse(col[..^1]))
31+
)
32+
);
33+
34+
long Solve(IEnumerable<Problem> problems) {
35+
var res = 0L;
36+
foreach (var problem in problems) {
37+
if (problem.op == '+') {
38+
res += problem.nums.Sum();
39+
} else {
40+
res += problem.nums.Aggregate(1L, (a, b) => a * b);
41+
}
42+
}
43+
return res;
44+
}
45+
46+
IEnumerable<string[]> ParseBlocks(string input) {
47+
var lines = input.Split("\n");
48+
int ccol = lines[0].Length;
49+
var blockStart = 0;
50+
for (int icol = 0; icol < ccol; icol++) {
51+
if (GetColumn(lines, icol).Trim() == "") {
52+
yield return GetBlock(lines, blockStart, icol);
53+
blockStart = icol+1;
54+
}
55+
}
56+
yield return GetBlock(lines, blockStart, ccol);
57+
}
58+
59+
string[] GetBlock(string[] lines, int icolFrom, int icolTo) => (
60+
from line in lines
61+
select line[icolFrom..icolTo]
62+
).ToArray();
63+
64+
string[] Transpose(string[] lines) => (
65+
from icol in Enumerable.Range(0, lines[0].Length)
66+
select GetColumn(lines, icol)
67+
).ToArray();
68+
69+
string GetColumn(string[] lines, int icol) =>
70+
string.Join("", from line in lines select line[icol]);
71+
}

2025/Day06/input.in

18.2 KB
Binary file not shown.

2025/Day06/input.refout

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4693159084994
2+
11643736116335

2025/SplashScreen.cs

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ public void Show() {
88

99
var color = Console.ForegroundColor;
1010
Write(0xcc00, false, " ▄█▄ ▄▄█ ▄ ▄ ▄▄▄ ▄▄ ▄█▄ ▄▄▄ ▄█ ▄▄ ▄▄▄ ▄▄█ ▄▄▄\n █▄█ █ █ █ █ █▄█ █ █ █ █ █ █▄ ");
11-
Write(0xcc00, false, " █ █ █ █ █ █▄█\n █ █ █▄█ ▀▄▀ █▄▄ █ █ █▄ █▄█ █ █▄ █▄█ █▄█ █▄▄ λy.2025\n \n ");
12-
Write(0xcc00, false, " ");
13-
Write(0xffffff, false, ".'. ' ____ '.' . ");
14-
Write(0xffff66, true, "* ");
15-
Write(0xffffff, false, ".. . .' . ");
11+
Write(0xcc00, false, " █ █ █ █ █ █▄█\n █ █ █▄█ ▀▄▀ █▄▄ █ █ █▄ █▄█ █ █▄ █▄█ █▄█ █▄▄ $year = 2025\n ");
12+
Write(0xcc00, false, "\n ");
13+
Write(0xffffff, false, "' ____ '' . ");
14+
Write(0xffff66, true, "* ");
15+
Write(0xffffff, false, ". .' . ");
1616
Write(0xff9900, false, "<");
17-
Write(0xffffff, false, "o ' . \n ________/");
17+
Write(0xffffff, false, "o . \n ________/");
1818
Write(0x999999, false, "O___");
1919
Write(0xffffff, false, "\\__________");
2020
Write(0xff0000, false, "|");
2121
Write(0xffffff, false, "_________________O______ ");
2222
Write(0xcccccc, false, " 1 ");
2323
Write(0xffff66, false, "**\n ");
24-
Write(0x32211a, false, ". ");
24+
Write(0x32211a, false, "'. ");
2525
Write(0x999999, false, "_______");
2626
Write(0xaabbcc, false, "||");
27-
Write(0x999999, false, "_________ ");
28-
Write(0x32211a, false, ". . .'. ' ' . \n . ");
27+
Write(0x999999, false, "_________ ");
28+
Write(0x32211a, false, "'. . ? ' ' . .' \n . ");
2929
Write(0x999999, false, "| ");
3030
Write(0x9b715b, false, "_");
3131
Write(0xbb66ff, false, "@");
@@ -61,8 +61,8 @@ public void Show() {
6161
Write(0x666666, false, ". ");
6262
Write(0xff0000, false, ".");
6363
Write(0x666666, false, ". ");
64-
Write(0x999999, false, "| \n ");
65-
Write(0x32211a, false, "' ' ");
64+
Write(0x999999, false, "| \n ");
65+
Write(0x32211a, false, ".' . .. .. ");
6666
Write(0x999999, false, "\\_");
6767
Write(0xaabbcc, false, "]");
6868
Write(0x999999, false, "__");
@@ -78,8 +78,8 @@ public void Show() {
7878
Write(0xaabbcc, false, "//");
7979
Write(0x999999, false, "_| ");
8080
Write(0xcccccc, false, " 3 ");
81-
Write(0xffff66, false, "**\n ");
82-
Write(0x32211a, false, ". . ' . ' ");
81+
Write(0xffff66, false, "**\n ");
82+
Write(0x32211a, false, ". '?' '. .' '''' ' ");
8383
Write(0x999999, false, "____________");
8484
Write(0xaabbcc, false, "//");
8585
Write(0x999999, false, "___ \n __________________________ ");
@@ -138,12 +138,27 @@ public void Show() {
138138
Write(0x999999, false, "_");
139139
Write(0xaa7744, false, "...' ");
140140
Write(0xcccccc, false, " 5 ");
141+
Write(0xffff66, false, "**\n ");
142+
Write(0x9900, false, "|| ");
143+
Write(0x32211a, false, "'");
144+
Write(0x666666, false, " ____________ \n ");
145+
Write(0x999999, false, "_");
146+
Write(0x9900, false, "||");
147+
Write(0x999999, false, "__");
148+
Write(0x666666, false, "/ \\_ ");
149+
Write(0xcccccc, false, " 6 ");
141150
Write(0xffff66, false, "**\n ");
142-
Write(0x333333, false, " || \n _||__ ");
143-
Write(0x333333, false, " ");
144-
Write(0x666666, false, " 6\n ");
145-
Write(0x333333, false, "| | \n |___] ");
146-
Write(0x333333, false, " ");
151+
Write(0x999999, false, "|");
152+
Write(0xff00, false, "^");
153+
Write(0xbb66ff, false, "@ ");
154+
Write(0x999999, false, "|");
155+
Write(0x333333, false, " 1 2 3 | \n ");
156+
Write(0x999999, false, "|");
157+
Write(0xff0000, false, "&");
158+
Write(0xffff66, false, "%");
159+
Write(0xaaaa, false, ";");
160+
Write(0xaabbcc, false, "]");
161+
Write(0x333333, false, "__[]_[]_[]__<>| ");
147162
Write(0x666666, false, " 7\n \n ");
148163
Write(0x666666, false, " 8\n ");
149164
Write(0x666666, false, " \n 9\n ");

0 commit comments

Comments
 (0)