Exemplo n.º 1
0
        public override string GetSolution()
        {
            long output = 0;

            NumberSequence phaseSetting = new NumberSequence(5, 4);

            while (true)
            {
                if (phaseSetting.IsUnique())
                {
                    long ampOutput = 0;
                    for (int i = 0; i < amps.Length; i++)
                    {
                        amps[i].Load();
                        amps[i].AddInput(phaseSetting[i]);
                        amps[i].AddInput(ampOutput);
                        amps[i].Run();
                        ampOutput = amps[i].GetOutput();
                    }

                    if (ampOutput > output)
                    {
                        output = ampOutput;
                    }
                }

                if (!phaseSetting.Increase())
                {
                    break;
                }
            }

            return(output.ToString());
        }
Exemplo n.º 2
0
        public override string GetSolution()
        {
            for (int i = 0; i < 6; i++)
            {
                code.SetValue(i, int.Parse(inputCodes[0].Substring(i, 1)));
            }

            int validCodes = 0;

            Console.WriteLine(code.GetFullNumber());
            while (code.GetFullNumber() < codeTo)
            {
                if (IsNumberValid(code.GetSequence()))
                {
                    validCodes++;
                    Console.WriteLine(code.GetFullNumber());
                }

                code.Increase();
            }

            return(validCodes.ToString());
        }