public override string Run() { var input = Tools.GetFileContents("dec5"); var inputArray = IntcodeMachine.GetInputArray(input); var shifter = new IntcodeMachine(inputArray); shifter.QueueInput(1); var result = shifter.ExecuteProgram(); sb.AppendLine($"\n\tPart 1: {result.ToString()}"); inputArray = IntcodeMachine.GetInputArray(input); shifter.LoadProgram(inputArray); shifter.QueueInput(5); result = shifter.ExecuteProgram(); sb.AppendLine($"\n\tPart 2: {result.ToString()}"); return(sb.ToString()); }
public override string Run() { var input = Tools.GetFileContents("dec7"); var defaultProgram = IntcodeMachine.GetInputArray(input); var thrusterSeqsP1 = generateAllPermutations(new List <int> { 0, 1, 2, 3, 4 }); var thrusterSeqsP2 = generateAllPermutations(new List <int> { 5, 6, 7, 8, 9 }); var outputP1 = RunAmplifiers(thrusterSeqsP1, (int[])defaultProgram.Clone()); var outputP2 = RunAmplifiers(thrusterSeqsP2, (int[])defaultProgram.Clone()); sb.AppendLine($"\n\tPart 1: {outputP1.ToString()}"); sb.AppendLine($"\n\tPart 2: {outputP2.ToString()}"); return(sb.ToString()); }
public override string Run() { var input = Tools.GetFileContents("dec2"); var inputArray = IntcodeMachine.GetInputArray(input); var replacements = new Dictionary <int, int> { { 1, 12 }, { 2, 2 } }; inputArray = IntcodeMachine.ReplaceValues(inputArray, replacements); var intcode = new IntcodeMachine(inputArray); var output = intcode.Alarm(); sb.AppendLine($"\n\tPart 1: {output.ToString()}"); inputArray = IntcodeMachine.GetInputArray(input); var output2 = intcode.FindVerbNouns(19690720, inputArray); var answer2 = output2.Key * 100 + output2.Value; sb.AppendLine($"\tPart 2: {answer2.ToString()}"); return(sb.ToString()); }