public void SolveDayTwo() { string resultsFile = "adventDayTwoSolution.txt"; string dataFile = "adventDayTwo.txt"; string outFile = Path.Combine(baseDir, resultsFile); string inFile = Path.Combine(baseDir, dataFile); string[] sourceData = ReadAllLines(inFile); // should be one line IntComputer newComp = new IntComputer(); newComp.InitializeMemoryFromFile(inFile); // we need to find the values that give us 19690720 in address 0 after running. Reset each time. if (FindNounVerb(newComp)) { newComp.WriteMemoryToFile(outFile); long val = 100 * newComp.ReadMemoryAtAddress(1) + newComp.ReadMemoryAtAddress(2); } else { Console.WriteLine("FAIL"); } //19690720 }
public bool FindNounVerb(IntComputer newComp) { for (int intI = 0; intI < 100; intI++) { for (int intJ = 0; intJ < 100; intJ++) { newComp.ResetMemory(); newComp.ReplaceMemoryAtAddress(1, (long)intI); newComp.ReplaceMemoryAtAddress(2, (long)intJ); newComp.StartComputer(false); long result = newComp.ReadMemoryAtAddress(0); if (result == 19690720) { // ALL DONE return(true); } } } return(false); }
long ReadParamMemory() { return(curComputer.ReadMemoryAtAddress((int)paramData)); }