public Resistor addResistor(WireGrid pos, WireGrid neg, float val) { if (resistors == null) resistors = new ArrayList(); Resistor r = new Resistor(Grid.grid(pos), Grid.grid(neg), val); resistors.Add(r); return r; }
public void Solve() { Logger.Start(nameof(DayThreePartOneProblem)); IWireGrid wireGrid = new WireGrid(); foreach (string input in GetInput()) { wireGrid.TraceWire(input); } int closestDistance = wireGrid.GetDistanceToClosestIntersection(); Logger.Log($"{Environment.NewLine}The closest intersection is {closestDistance}."); Logger.Complete(nameof(DayThreePartOneProblem)); }
public override void Load(TagCompound tag) { try { wires.Load((TagCompound)tag["Wires"]); heatPipes.Load((TagCompound)tag["HeatPipes"]); foreach (Wire wire in wires.elements.Values) { WireGrid grid = new WireGrid(); grid.energy.SetCapacity(wire.maxIO * 2); grid.energy.SetMaxTransfer(wire.maxIO); grid.tiles.Add(wire); grid.energy.ModifyEnergyStored(wire.share); wire.share = 0; wire.grid = grid; } foreach (Wire wire in wires.elements.Values) { wire.Merge(); } foreach (HeatPipe heatPipe in heatPipes.elements.Values) { HeatPipeGrid grid = new HeatPipeGrid(); grid.tiles.Add(heatPipe); heatPipe.grid = grid; } foreach (HeatPipe heatPipe in heatPipes.elements.Values) { heatPipe.Merge(); } } catch (Exception ex) { ErrorLogger.Log(ex); } }
public static Grid grid(WireGrid w) { if (gridGrid == null) gridGrid = new Hashtable(); if (!gridGrid.ContainsKey(w)) { gridGrid.Add(w, new Grid(w)); w.setVoltage(-1); } return gridGrid[w] as Grid; }
Grid(WireGrid corres_grid) { nComponents = 0; V = -1; corres_Grid = corres_grid; }
public Day03Solutions(ITestOutputHelper helper) : base(helper) { _wireGrid = new WireGrid(); }