public Path PathWithNewCoordsAndDirection(Coords newCoords, Direction direction, int maxDirectionChanges) { var isActive = PathUtils.IsActiveWithNewCoords(this, newCoords, direction, maxDirectionChanges); var newNumDirectionChanges = NumDirectionChanges + (direction != Direction ? 1 : 0); return(new Path(CoordsList.Concat(new[] { newCoords }).ToArray(), direction, newNumDirectionChanges, isActive)); }
private void OnNewPointButton_Click(object sender, RoutedEventArgs e) { CurrentPointNumber++; SharpKml.Base.Vector coord = new SharpKml.Base.Vector(0, 0); CoordsList.Add(coord); EditPointControl pointControl = new EditPointControl(coord, CurrentPointNumber); this.Stack.Children.Add(pointControl); }
public void BuildGrid() { var width = Math.Max(CoordsList.Max(x => x.XStarting), CoordsList.Max(x => x.XEnding)) + 1; var height = Math.Max(CoordsList.Max(y => y.YStarting), CoordsList.Max(y => y.YEnding)) + 1; for (int y = 0; y < height; y++) { Grid.Add(new List <int>(new int[width])); } }
public void ReadInput() { var puzzleInput = new List <string>(); var path = Path.Combine(Directory.GetCurrentDirectory(), InputFile); var result = new List <string>(); using (var reader = File.OpenText(path)) { var line = reader.ReadLine(); while (line != null) { var x1 = Int32.Parse(line.Split(',')[0]); var y2 = Int32.Parse(line.Split(',')[2]); var insideInput = line.Split(',')[1]; var y1 = Int32.Parse(insideInput.Split(new char[0])[0]); var x2 = Int32.Parse(insideInput.Split(new char[0])[2]); CoordsList.Add(new Coords(x1, y1, x2, y2)); line = reader.ReadLine(); } } }
private string CoordsListToString() { return(string.Join(", ", CoordsList.Select(c => c.ToString()).ToArray())); }
public Path PathWithEndCoords(Coords endCoords) { return(new Path(CoordsList.Concat(new[] { endCoords }).ToArray(), Direction, NumDirectionChanges, true)); }