Refactor Day02 waypoint lookup and Day03 corner helper
This commit is contained in:
1 parent
c5732e107f
commit
5fd9cc26d8
2 files changed
+9
-17
No files matched your search
+3
-11
@@ -5,15 +5,7 @@ namespace AoC_2026;
|
||||
|
||||
public class Day02 : IPuzzleSolver<long>
|
||||
{
|
||||
private static readonly Dictionary<char,int> WaypointIndex = new Dictionary<char,int>()
|
||||
{
|
||||
['r'] = 0,
|
||||
['o'] = 1,
|
||||
['y'] = 2,
|
||||
['g'] = 3,
|
||||
['b'] = 4,
|
||||
['v'] = 5
|
||||
};
|
||||
private const string WaypointSequence = "roygbv";
|
||||
|
||||
private string ParsePuzzleInput(string path)
|
||||
{
|
||||
@@ -39,8 +31,8 @@ public class Day02 : IPuzzleSolver<long>
|
||||
|
||||
private static int GetDistance(char current, char next)
|
||||
{
|
||||
var dist = WaypointIndex[next] - WaypointIndex[current];
|
||||
return dist > 0 ? dist : dist + WaypointIndex.Count;
|
||||
var dist = WaypointSequence.IndexOf(next) - WaypointSequence.IndexOf(current);
|
||||
return dist > 0 ? dist : dist + WaypointSequence.Length;
|
||||
}
|
||||
|
||||
public long SolvePart2(string pathToPuzzleInput)
|
||||
|
||||
Reference in new issue
Block a user