public static async Task <long> AmplificationCircuitWithFeedbackLoop(long[] program) { var combinations = UtilsDay7.GetCombinations(5, 9); long result = 0; foreach (var combination in combinations) { var candidate = await ExecuteCombinationWithFeedback(program, combination); result = candidate > result ? candidate : result; } return(result); }
public static long AmplificationCircuit(long[] program) { var combinations = UtilsDay7.GetCombinations(0, 4); long outputE = 0; foreach (var c in combinations) { var outputA = ExecuteAmplifierControllerSoftware(program, c.A, 0); var outputB = ExecuteAmplifierControllerSoftware(program, c.B, outputA); var outputC = ExecuteAmplifierControllerSoftware(program, c.C, outputB); var outputD = ExecuteAmplifierControllerSoftware(program, c.D, outputC); var tmp = ExecuteAmplifierControllerSoftware(program, c.E, outputD); outputE = tmp > outputE ? tmp : outputE; } return(outputE); }