public override void PartOne() { var order = Comparing <Particle> .By(p => p.Acceleration.Magnitude()) .ThenBy(p => p.Velocity.Magnitude()) .ThenBy(p => p.Pos.Magnitude()); var result = ReadParticles().OrderBy(order).First().Num; WriteLn(result); }
public override void PartOne() { var graph = Input.ToDigraph(s => s[5], s => s[36]); var queue = new SelfPriorityQueue <Vertex <char, DirectedEdge <char> > >(Comparing <Vertex <char, DirectedEdge <char> > > .By(vertex => vertex.Value)); foreach (var vertex in graph.Where(vertex => !graph.HasIncomingEdges(vertex))) { queue.Enqueue(vertex); } while (queue.Count > 0) { var vertex = queue.Dequeue(); Write(vertex.Value); var next = vertex.Neighbors.ToList(); graph.RemoveVertex(vertex); foreach (var v in next.Where(v => !graph.HasIncomingEdges(v))) { queue.Enqueue(v); } } NewLine(); }