예제 #1
0
 public void PositionModeLessThanTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #2
0
 public void ImmediateModeLessThanTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 3, 1107, -1, 8, 3, 4, 3, 99 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #3
0
 public void Part2()
 {
     SetNextInput(5);
     CreateAndRunComputer(new[] { 3, 225, 1, 225, 6, 6, 1100, 1, 238, 225, 104, 0, 1001, 210, 88, 224, 101, -143, 224, 224, 4, 224, 1002, 223, 8, 223, 101, 3, 224, 224, 1, 223, 224, 223, 101, 42, 92, 224, 101, -78, 224, 224, 4, 224, 1002, 223, 8, 223, 1001, 224, 3, 224, 1, 223, 224, 223, 1101, 73, 10, 225, 1102, 38, 21, 225, 1102, 62, 32, 225, 1, 218, 61, 224, 1001, 224, -132, 224, 4, 224, 102, 8, 223, 223, 1001, 224, 5, 224, 1, 224, 223, 223, 1102, 19, 36, 225, 102, 79, 65, 224, 101, -4898, 224, 224, 4, 224, 102, 8, 223, 223, 101, 4, 224, 224, 1, 224, 223, 223, 1101, 66, 56, 224, 1001, 224, -122, 224, 4, 224, 102, 8, 223, 223, 1001, 224, 2, 224, 1, 224, 223, 223, 1002, 58, 82, 224, 101, -820, 224, 224, 4, 224, 1002, 223, 8, 223, 101, 3, 224, 224, 1, 223, 224, 223, 2, 206, 214, 224, 1001, 224, -648, 224, 4, 224, 102, 8, 223, 223, 101, 3, 224, 224, 1, 223, 224, 223, 1102, 76, 56, 224, 1001, 224, -4256, 224, 4, 224, 102, 8, 223, 223, 1001, 224, 6, 224, 1, 223, 224, 223, 1102, 37, 8, 225, 1101, 82, 55, 225, 1102, 76, 81, 225, 1101, 10, 94, 225, 4, 223, 99, 0, 0, 0, 677, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1105, 0, 99999, 1105, 227, 247, 1105, 1, 99999, 1005, 227, 99999, 1005, 0, 256, 1105, 1, 99999, 1106, 227, 99999, 1106, 0, 265, 1105, 1, 99999, 1006, 0, 99999, 1006, 227, 274, 1105, 1, 99999, 1105, 1, 280, 1105, 1, 99999, 1, 225, 225, 225, 1101, 294, 0, 0, 105, 1, 0, 1105, 1, 99999, 1106, 0, 300, 1105, 1, 99999, 1, 225, 225, 225, 1101, 314, 0, 0, 106, 0, 0, 1105, 1, 99999, 8, 226, 677, 224, 102, 2, 223, 223, 1005, 224, 329, 101, 1, 223, 223, 1008, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 344, 1001, 223, 1, 223, 107, 226, 677, 224, 102, 2, 223, 223, 1005, 224, 359, 1001, 223, 1, 223, 1108, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 374, 101, 1, 223, 223, 1107, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 389, 101, 1, 223, 223, 108, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 404, 101, 1, 223, 223, 7, 677, 677, 224, 102, 2, 223, 223, 1006, 224, 419, 101, 1, 223, 223, 108, 677, 677, 224, 102, 2, 223, 223, 1006, 224, 434, 1001, 223, 1, 223, 7, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 449, 1001, 223, 1, 223, 108, 226, 226, 224, 102, 2, 223, 223, 1005, 224, 464, 101, 1, 223, 223, 8, 226, 226, 224, 1002, 223, 2, 223, 1006, 224, 479, 101, 1, 223, 223, 1008, 226, 226, 224, 102, 2, 223, 223, 1005, 224, 494, 1001, 223, 1, 223, 1008, 677, 226, 224, 1002, 223, 2, 223, 1005, 224, 509, 101, 1, 223, 223, 7, 677, 226, 224, 102, 2, 223, 223, 1006, 224, 524, 101, 1, 223, 223, 1007, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 539, 1001, 223, 1, 223, 1108, 677, 226, 224, 102, 2, 223, 223, 1005, 224, 554, 1001, 223, 1, 223, 8, 677, 226, 224, 1002, 223, 2, 223, 1005, 224, 569, 101, 1, 223, 223, 1108, 226, 677, 224, 1002, 223, 2, 223, 1005, 224, 584, 101, 1, 223, 223, 1107, 677, 226, 224, 102, 2, 223, 223, 1006, 224, 599, 101, 1, 223, 223, 107, 226, 226, 224, 102, 2, 223, 223, 1006, 224, 614, 1001, 223, 1, 223, 107, 677, 677, 224, 1002, 223, 2, 223, 1005, 224, 629, 1001, 223, 1, 223, 1107, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 644, 101, 1, 223, 223, 1007, 677, 677, 224, 102, 2, 223, 223, 1006, 224, 659, 1001, 223, 1, 223, 1007, 226, 226, 224, 1002, 223, 2, 223, 1006, 224, 674, 1001, 223, 1, 223, 4, 223, 99, 226 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(11826654);
 }
예제 #4
0
 public void Test1()
 {
     SetNextInput(666);
     CreateAndRunComputer(new[] { 3, 0, 4, 0, 99 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(666);
 }
예제 #5
0
 public void LargeExampleTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20, 31, 1106, 0, 36, 98, 0, 0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46, 104, 999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20, 1105, 1, 46, 98, 99 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #6
0
 public void ImmediateModeJumpTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 3, 1105, -1, 9, 1101, 0, 0, 12, 4, 12, 99, 1 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #7
0
 public void PositionModeJumpTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 12, 6, 12, 15, 1, 13, 14, 13, 4, 13, 99, -1, 0, 1, 9 });
     State.ShouldBe(State.Terminated);
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #8
0
 public void OutputRelativeModeTest()
 {
     CreateAndRunComputer(new[] { 9, 3, 204, 1, 99 });
     LastOutput.ShouldBe(204);
 }
예제 #9
0
 public void OutputImmediateModeTest()
 {
     CreateAndRunComputer(new[] { 104, 66, 99 });
     LastOutput.ShouldBe(66);
 }
예제 #10
0
 public void OutputPositionModeTest()
 {
     CreateAndRunComputer(new[] { 4, 1, 99 });
     LastOutput.ShouldBe(1);
 }
예제 #11
0
 public void JumpIfFalseRelativeModeTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 100, 109, 10, 2006, 100, 0, 104, 10, 99, 11, 104, 100, 99 });
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #12
0
 public void JumpIfFalsePositionModeTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 100, 6, 100, 8, 104, 10, 99, 9, 104, 100, 99 });
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #13
0
 public void JumpIfTrueImmediateModeTest(long input, long expectedOutput)
 {
     SetNextInput(input);
     CreateAndRunComputer(new[] { 3, 100, 1005, 100, 8, 104, 10, 99, 104, 100, 99 });
     LastOutput.ShouldBe(expectedOutput);
 }
예제 #14
0
 public void Example3()
 {
     CreateAndRunComputer(new[] { 104, 1125899906842624, 99 });
     LastOutput.ShouldBe(1125899906842624);
 }
예제 #15
0
 public void Example2()
 {
     CreateAndRunComputer(new[] { 1102, 34915192, 34915192, 7, 4, 7, 99, 0 });
     LastOutput.ShouldBe(1219070632396864);
 }