public static IntMove ApplyGravity(IntMove source, IntMove target) { if (source.X > target.X) { target.VX++; } if (source.X < target.X) { target.VX--; } if (source.Y > target.Y) { target.VY++; } if (source.Y < target.Y) { target.VY--; } if (source.Z > target.Z) { target.VZ++; } if (source.Z < target.Z) { target.VZ--; } return(target); }
public static IntMove ParseVector(string vectorInput) { var vectorArray = vectorInput.Split(',').Select(StripBraces).Select(StripName).ToArray(); var a = new IntMove { X = vectorArray[0], Y = vectorArray[1], Z = vectorArray[2] }; return(a); }
public static IntMove UpdateWithGravity(IntMove a, IEnumerable <IntMove> l) { var influencers = l.Except(new[] { a }).ToArray(); var target = a; foreach (var source in influencers) { target = ApplyGravity(source, target); } return(target); }
public static int CalcPotOne(IntMove a) { return(Math.Abs(a.X) + Math.Abs(a.Y) + Math.Abs(a.Z)); }
public static int CalcKinOne(IntMove a) { return(Math.Abs(a.VX) + Math.Abs(a.VY) + Math.Abs(a.VZ)); }