-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay25.cs
More file actions
76 lines (60 loc) · 1.74 KB
/
Day25.cs
File metadata and controls
76 lines (60 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Collections.Immutable;
using System.Collections.Specialized;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using _2024.Utils;
namespace _2024._25;
public class Day25 : Base
{
private readonly List<List<int>> _locks = [];
private readonly List<List<int>> _keys = [];
const int rows = 7;
public Day25(bool example) : base(example)
{
Day = "25";
string[] input = ReadInput();
for (int schematic = 0; schematic < input.Length; schematic += rows+1)
{
//
List<int> currSchematic =
[
0, 0, 0, 0, 0,
];
for (int row = 0; row < rows; row++)
{
foreach((char c, int idx) in input[schematic + row].Enumerate())
{
if (c == '#')
{
currSchematic[idx]++;
}
}
}
// key
if (input[schematic].Contains('.'))
{
_keys.Add(currSchematic);
}
// lock
else
{
_locks.Add(currSchematic);
}
}
}
private static bool Overlap(int lockPin, int keyHeight) => lockPin - 1 > (rows - keyHeight - 1);
public override object PartOne()
{
return _locks.Sum(_lock => _keys.Count(key => !_lock.Zip(key, Overlap).Any(o => o)));
}
public override object PartTwo()
{
return "You did it.";
}
public override void Reset()
{
}
}