public void Test_Add_1_And_2_Updates_Position_3_To_3() { int[] codes = { 1, 1, 2, 1 }; var result = AlarmProcessor.Calculate((OpCode)codes[0], codes[1], codes[2]); Assert.Equal(3, result); }
public void Test_Multiply_2_And_3_Updates_Position_3_To_6() { int[] codes = { 2, 2, 3, 3 }; var result = AlarmProcessor.Calculate((OpCode)codes[0], codes[1], codes[2]); Assert.Equal(6, result); }
public static int ProcessOpCodes(int[] codes, int noun, int verb) { codes[1] = noun; codes[2] = verb; for (var i = 0; i < codes.Length; i += 4) { if (!Enum.IsDefined(typeof(OpCode), codes[i])) { break; } codes[codes[i + 3]] = AlarmProcessor.Calculate( (OpCode)codes[i], codes[codes[i + 1]], codes[codes[i + 2]] ); } return(codes[0]); }