day07 task 1

This commit is contained in:
Johannes
2019-12-08 20:26:31 +01:00
parent 864e4f7446
commit 0db2018217
5 changed files with 35 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ pub fn run() {
task2(ram.clone());
}
struct IntCodeComputer {
pub struct IntCodeComputer {
input_storage: Vec<i32>,
output_storage: Vec<i32>,
pc: usize,
@@ -140,7 +140,7 @@ impl Op {
}
impl IntCodeComputer {
fn new(input: Vec<i32>, memory: Vec<i32>) -> Self {
pub fn new(input: Vec<i32>, memory: Vec<i32>) -> Self {
IntCodeComputer {
input_storage: input,
output_storage: Vec::new(),
@@ -149,7 +149,7 @@ impl IntCodeComputer {
}
}
fn run_until_end(&mut self) {
pub fn run_until_end(&mut self) {
let mut op = Op::from(self.pc, &self.ram);
let mut inputs = self.input_storage.iter();
while op.opcode != OpCode::Terminate {
@@ -212,7 +212,7 @@ impl IntCodeComputer {
}
}
fn get_output(&self) -> &[i32] {
pub fn get_output(&self) -> &[i32] {
self.output_storage.as_slice()
}
}