protected bool Equals(Moon other) { return(this.X == other.X && this.Y == other.Y && this.Z == other.Z && this.VelocityX == other.VelocityX && this.VelocityY == other.VelocityY && this.VelocityZ == other.VelocityZ); }
private static Moon[] ParseMoons(string[] input) { var parseRegex = new Regex("<x=(?<x>-?\\d+), y=(?<y>-?\\d+), z=(?<z>-?\\d+)"); var moons = input.Select(l => { var match = parseRegex.Match(l).Groups; var result = new Moon() { X = int.Parse(match["x"].Value), Y = int.Parse(match["y"].Value), Z = int.Parse(match["z"].Value) }; return(result); }).ToArray(); return(moons); }
private void ApplyGravity(Moon moon) { VelX = moon.PosX switch { var refX when PosX <refX => ++ VelX, var refX when PosX> refX => -- VelX, _ => VelX }; VelY = moon.PosY switch { var refY when PosY <refY => ++ VelY, var refY when PosY> refY => -- VelY, _ => VelY }; VelZ = moon.PosZ switch { var refZ when PosZ <refZ => ++ VelZ, var refZ when PosZ> refZ => -- VelZ, _ => VelZ }; }
public MoonRelationship(Moon a, Moon b) { this.A = a; this.B = b; }