2019: day05: allow intcode creation with memory

This commit is contained in:
Antoine Martin 2019-12-07 17:43:15 +01:00
parent d44dca92a0
commit e468ec2952

View file

@ -108,13 +108,17 @@ impl Intcode {
.map(|x| x.parse().map_err(|e| err!("couldn't parse int: {}", e)))
.collect::<Result<Vec<i64>>>()?;
Ok(Intcode {
Ok(Intcode::with_memory(memory))
}
fn with_memory(memory: Vec<i64>) -> Self {
Intcode {
memory,
input: Vec::new(),
output: Vec::new(),
ip: 0,
next_input: 0,
})
}
}
fn add_input(&mut self, value: i64) {