namespace Day17; public record struct Vec { public int X { get; } public int Y { get; } public bool IsHorizontal => Y == 0; public bool IsVertical => X == 0; public Vec(int x, int y) { X = x; Y = y; } public Vec RotatePositive() { // clockwise return new Vec(-1 * Y, X); } public Vec RotateNegative() { // counter-clockwise return new Vec(Y, -1 * X); } public Vec Add(Vec other) { return new Vec(X + other.X, Y + other.Y); } public int Cross(Vec other) { return X * other.Y - other.X * Y; } public static Vec Direction(char c) { switch (c) { case 'R': return new Vec(1, 0); case 'L': return new Vec(-1, 0); case 'U': return new Vec(0, -1); case 'D': return new Vec(0, 1); } return default; } }