move input parsing into vm class
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
eb284a98c6
commit
663d31564a
3
Day7.cs
3
Day7.cs
|
@ -12,8 +12,7 @@ namespace aoc2019
|
|||
private readonly IntCodeVM[] Amplifiers = new IntCodeVM[5];
|
||||
public Day7()
|
||||
{
|
||||
var input = Input.First().Split(',').Select(long.Parse);
|
||||
for (var i = 0; i < 5; i++) Amplifiers[i] = new IntCodeVM(input);
|
||||
for (var i = 0; i < 5; i++) Amplifiers[i] = new IntCodeVM(Input.First());
|
||||
}
|
||||
|
||||
|
||||
|
|
2
Day9.cs
2
Day9.cs
|
@ -12,7 +12,7 @@ namespace aoc2019
|
|||
|
||||
public Day9()
|
||||
{
|
||||
vm = new IntCodeVM(Input.First().Split(',').Select(long.Parse));
|
||||
vm = new IntCodeVM(Input.First());
|
||||
}
|
||||
|
||||
public override string Part1()
|
||||
|
|
|
@ -12,12 +12,12 @@ namespace aoc2019.lib
|
|||
private readonly long[] program;
|
||||
public Queue<long> input, output;
|
||||
|
||||
public IntCodeVM(IEnumerable<long> tape)
|
||||
public IntCodeVM(string tape)
|
||||
{
|
||||
i = 0;
|
||||
relbase = 0;
|
||||
program = tape.ToArray();
|
||||
memory = tape.ToArray();
|
||||
program = tape.Split(',').Select(long.Parse).ToArray();
|
||||
memory = program;
|
||||
input = new Queue<long>();
|
||||
output = new Queue<long>();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue