namespace Day21; public record struct Vec { public static Vec Zero { get; } = new Vec(0, 0); public long X { get; } public long Y { get; } public bool IsHorizontal => Y == 0; public bool IsVertical => X == 0; public Vec(long x, long 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 Vec Multiply(int f) { return new Vec(f * X, f * Y); } public long 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; } }