Skip to content

Commit 2aaf75e

Browse files
committed
2025/02
1 parent 2c88b50 commit 2aaf75e

6 files changed

Lines changed: 95 additions & 17 deletions

File tree

2025/Day02/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## --- Day 2: Gift Shop ---
2+
You get inside and take the elevator to its only other stop: the gift shop. "Thank you for visiting the North Pole!" gleefully exclaims a nearby sign. You aren't sure who is even allowed to visit the North Pole, but you know you can access the lobby through here, and from there you can access the rest of the North Pole base.
3+
4+
As you make your way through the surprisingly extensive selection, one of the clerks recognizes you and asks for your help.
5+
6+
_Visit the website for the full story and [full puzzle](https://adventofcode.com/2025/day/2) description._

2025/Day02/Solution.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
namespace AdventOfCode.Y2025.Day02;
2+
3+
using System;
4+
using System.Linq;
5+
using System.Collections.Generic;
6+
7+
[ProblemName("Gift Shop")]
8+
class Solution : Solver {
9+
10+
public object PartOne(string input) => Solve(input, st => 2);
11+
12+
public object PartTwo(string input) => Solve(input, st => st.Length);
13+
14+
long Solve(string input, Func<string, int> maxRepetition) => (
15+
from id in GetIds(input)
16+
let st = id.ToString()
17+
where Enumerable.Range(2, maxRepetition(st)-1).Any(k => Periodic(st, k))
18+
select id
19+
).Sum();
20+
21+
public IEnumerable<long> GetIds(string input) {
22+
foreach (var range in input.Split(",")) {
23+
var parts = range.Split("-").Select(long.Parse).ToArray();
24+
for (var i = parts[0]; i <= parts[1]; i++) {
25+
yield return i;
26+
}
27+
}
28+
}
29+
30+
// Returns true if the string consists of the same substring repeated repetitionCount times.
31+
// Example: repetitionCount == 3 returns true for "abcabcabc".
32+
bool Periodic(string st, int repetitionCount) {
33+
if (st.Length % repetitionCount != 0) {
34+
return false;
35+
}
36+
37+
int period = st.Length / repetitionCount;
38+
for (int i = period; i < st.Length; i += period) {
39+
if (st[..period] != st[i..(i + period)]) {
40+
return false;
41+
}
42+
}
43+
return true;
44+
}
45+
}

2025/Day02/input.in

569 Bytes
Binary file not shown.

2025/Day02/input.refout

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

2025/SplashScreen.cs

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

99
var color = Console.ForegroundColor;
1010
Write(0xcc00, false, " ▄█▄ ▄▄█ ▄ ▄ ▄▄▄ ▄▄ ▄█▄ ▄▄▄ ▄█ ▄▄ ▄▄▄ ▄▄█ ▄▄▄\n █▄█ █ █ █ █ █▄█ █ █ █ █ █ █▄ ");
11-
Write(0xcc00, false, " █ █ █ █ █ █▄█\n █ █ █▄█ ▀▄▀ █▄▄ █ █ █▄ █▄█ █ █▄ █▄█ █▄█ █▄▄ /* 2025 */\n \n ");
12-
Write(0xcc00, false, " ");
13-
Write(0xffffff, false, "'.'. ____ ' ... ");
11+
Write(0xcc00, false, " █ █ █ █ █ █▄█\n █ █ █▄█ ▀▄▀ █▄▄ █ █ █▄ █▄█ █ █▄ █▄█ █▄█ █▄▄ sub y{2025}\n \n");
12+
Write(0xcc00, false, " ");
13+
Write(0xffffff, false, "' ____ ' . ");
1414
Write(0xffff66, true, "* ");
15-
Write(0xffffff, false, "' . .' .. ");
15+
Write(0xffffff, false, "'. .' . '. ");
1616
Write(0xff9900, false, "<");
1717
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 ");
23-
Write(0xffff66, false, "**\n ");
24-
Write(0x333333, false, " _______||_________ \n | _@__ || _o_ | ");
25-
Write(0x333333, false, " ");
26-
Write(0x666666, false, " 2\n ");
27-
Write(0x333333, false, " |_&_%__||_oo__^=_[ \n ");
28-
Write(0x333333, false, " ");
23+
Write(0xffff66, false, "**\n ");
24+
Write(0x999999, false, "_______");
25+
Write(0xaabbcc, false, "||");
26+
Write(0x999999, false, "_________ \n | ");
27+
Write(0x9b715b, false, "_");
28+
Write(0xbb66ff, false, "@");
29+
Write(0x9b715b, false, "__ ");
30+
Write(0xaabbcc, false, "|| ");
31+
Write(0x9b715b, false, "_");
32+
Write(0x66ff, false, "o");
33+
Write(0x9b715b, false, "_ ");
34+
Write(0xff0000, false, "'.");
35+
Write(0x999999, false, "|");
36+
Write(0x666666, false, "_ _________________________ ");
37+
Write(0xcccccc, false, " 2 ");
38+
Write(0xffff66, false, "**\n ");
39+
Write(0x999999, false, "|_");
40+
Write(0xff0000, false, "&");
41+
Write(0x999999, false, "_");
42+
Write(0xffff66, false, "%");
43+
Write(0x999999, false, "__");
44+
Write(0xaabbcc, false, "||");
45+
Write(0x999999, false, "_");
46+
Write(0x66ff, false, "o");
47+
Write(0xff9900, false, "o");
48+
Write(0x999999, false, "__");
49+
Write(0xaabbcc, false, "^");
50+
Write(0x9b715b, false, "=");
51+
Write(0x999999, false, "_");
52+
Write(0x9b715b, false, "[");
53+
Write(0x333333, false, " \\| _ .. .. .. | \n \\_]__--|_|___[]_[]_[]__//_| ");
2954
Write(0x666666, false, " 3\n \n ");
3055
Write(0x666666, false, " 4\n ");
3156
Write(0x666666, false, " \n 5\n ");

2025/calendar.svg

Lines changed: 7 additions & 7 deletions
Loading

0 commit comments

Comments
 (0)