public int FindNounVerbValue(int value) { for (int noun = 0; noun < 100; noun++) { for (int verb = 0; verb < 100; verb++) { var intComputerWrapper = new IntComputerWrapper(noun, verb, _memory); try { var firstCharacter = intComputerWrapper.FirstCharacter; if (firstCharacter > value) { continue; } if (firstCharacter == value) { return((100 * noun) + verb); } } catch { } } } throw new ApplicationException("Value not found"); }
static void Main(string[] args) { Console.WriteLine("Where is the file located?"); var fileLocation = Console.ReadLine(); if (!File.Exists(fileLocation)) { Console.WriteLine("File not found!"); return; } var startingMemory = File.ReadAllText(fileLocation); var computer = new IntComputerWrapper(12,2,startingMemory); Console.WriteLine($"Part1:{computer.FirstCharacter}"); var nounAndVerbFinder = new NounAndVerbLocator(startingMemory); Console.WriteLine($"Part2: {nounAndVerbFinder.FindNounVerbValue(19690720)}"); }