| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- namespace Day17;
- public record struct Vec
- {
- public int X { get; }
- public int Y { get; }
- 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 char Arrow()
- {
- if (Y == 0)
- {
- return X > 0
- ? '>'
- : '<';
- }
- else
- {
- return Y > 0
- ? 'v'
- : '^';
- }
- }
- }
|