public void CalculateDistancesBetweenTiles() { StringInputReader reader = new StringInputReader(); HexWalker walker = new HexWalker(reader); Assert.Equal(3, walker.ShortestDistanceFromStart("ne,ne,ne")); Assert.Equal(0, walker.ShortestDistanceFromStart("ne,ne,sw,sw")); Assert.Equal(2, walker.ShortestDistanceFromStart("ne,ne,s,s")); Assert.Equal(3, walker.ShortestDistanceFromStart("se,sw,se,sw,sw")); }
static void Main(string[] args) { /** * I used the following extremely well-written guide by Amit Patel (Red Blob Games) * to understand how a hexogonal grid can be represented and how one traverses it: * * https://www.redblobgames.com/grids/hexagons * * It's one of the most nicely-presented resources on game development that I've * ever seen! */ FileInputReader reader = new FileInputReader(); HexWalker walker = new HexWalker(reader); // Part one Console.WriteLine(walker.ShortestDistanceFromStart("Inputs/day-11.txt")); // Part two Console.WriteLine(walker.FarthestDistanceFromStart("Inputs/day-11.txt")); }