static void Day3Part1(Day3Data MapData) { string line; long trees = 1; List <slope> slopes = new List <slope>(); slopes.Add(new slope(1, 1)); slopes.Add(new slope(3, 1)); slopes.Add(new slope(5, 1)); slopes.Add(new slope(7, 1)); slopes.Add(new slope(1, 2)); System.IO.StreamReader file = new System.IO.StreamReader(@".\Input\DayThreeInput.txt"); while ((line = file.ReadLine()) != null) { MapData.AddRow(line); } foreach (slope item in slopes) { MapData.resetData(); do { if (!MapData.setPosition(MapData.x + item.x, MapData.y + item.y)) { System.Console.WriteLine("Failed to set position ({0}, {1})", MapData.x, MapData.y); break; } }while(!MapData.AtBottom); System.Console.WriteLine("Trees Hit: {0}", MapData.TreesHit); trees = trees * MapData.TreesHit; } System.Console.WriteLine("Number of trees hit: {0}", trees); }
public static void DoDay3() { Day3Data MapData = new Day3Data(); Day3Part1(MapData); }