Esempio n. 1
0
 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;
 }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 Grid(WireGrid corres_grid)
 {
     nComponents = 0;
     V = -1;
     corres_Grid = corres_grid;
 }
Esempio n. 6
0
 public Day03Solutions(ITestOutputHelper helper) : base(helper)
 {
     _wireGrid = new WireGrid();
 }