Extract Coordinate, IntegerRange and Coordinate3d to new AdventOfCode.HelperClasses project and refactor solution for modularity and type consistency

This commit is contained in:
Sebastian Lindemeier
2025-12-12 13:14:17 +01:00
parent 85516cd783
commit aaf32260d0
13 changed files with 119 additions and 143 deletions
+25
View File
@@ -0,0 +1,25 @@
namespace AdventOfCode.HelperClasses;
public record Coordinate(long X, long Y)
{
public double GetEuclidianDistance(Coordinate other) =>
Math.Sqrt((X - other.X) * (X - other.X) + (Y - other.Y) * (Y - other.Y));
public static double GetEuclidianDistance(Coordinate a, Coordinate b) =>
Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
public static Coordinate operator +(Coordinate left, Coordinate right) =>
new(left.X + right.X, left.Y + right.Y);
}
public record Coordinate3d(long X, long Y, long Z)
{
public double GetEuclidianDistance(Coordinate3d other) =>
Math.Sqrt((X - other.X) * (X - other.X) + (Y - other.Y) * (Y - other.Y) + (Z - other.Z) * (Z - other.Z));
public static double GetEuclidianDistance(Coordinate3d a, Coordinate3d b) =>
Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y) + (a.Z - b.Z) * (a.Z - b.Z));
public static Coordinate3d operator +(Coordinate3d left, Coordinate3d right) =>
new(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
}