Esempio n. 1
0
        public object Solve()
        {
            var reactions = GetReactions().ToList();

            var nanoFactory = new NanoFactory(reactions);
            
            const long availableOre = 1000000000000;
            
            long fuelCount = 0;
            var fuelCreationStep = 1000000;
            
            while (fuelCreationStep >= 1)
            {
                while (nanoFactory.OreUsed < availableOre)
                {
                    nanoFactory.Create("FUEL", fuelCreationStep);
                    fuelCount += fuelCreationStep;
                }

                if (fuelCreationStep >= 1)
                {
                    nanoFactory.Rollback();
                    fuelCount -= fuelCreationStep;
                    fuelCreationStep /= 10;
                }
            }

            return fuelCount;
        }
Esempio n. 2
0
        public object Solve()
        {
            var reactions = GetReactions().ToList();

            var nanoFactory = new NanoFactory(reactions);

            nanoFactory.Create("FUEL", 1);

            return(nanoFactory.OreUsed);
        }