Add D21P1
This commit is contained in:
parent
970ad53ce5
commit
ec7bb8f408
|
@ -0,0 +1,10 @@
|
||||||
|
[package]
|
||||||
|
name = "d21"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["kageru <kageru@encode.moe>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
intcode = { path = "../intcode" }
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,21 @@
|
||||||
|
use intcode::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let program = "NOT A J
|
||||||
|
NOT B T
|
||||||
|
OR T J
|
||||||
|
NOT C T
|
||||||
|
OR T J
|
||||||
|
AND D J
|
||||||
|
WALK
|
||||||
|
"
|
||||||
|
.chars()
|
||||||
|
.map(|c| c as i64)
|
||||||
|
.rev()
|
||||||
|
.collect();
|
||||||
|
let part1 = IntComputer::new(read_input(), 0, program)
|
||||||
|
.get_all_outputs()
|
||||||
|
.pop()
|
||||||
|
.unwrap();
|
||||||
|
println!("{}", part1);
|
||||||
|
}
|
|
@ -128,7 +128,7 @@ impl IntComputer {
|
||||||
as usize,
|
as usize,
|
||||||
},
|
},
|
||||||
['0', '3'] => Operation::Input {
|
['0', '3'] => Operation::Input {
|
||||||
value: self.params.pop().unwrap(),
|
value: self.params.pop().expect("Encountered input instruction with empty parameters"),
|
||||||
addr: self.get_next_address(get_mode(&full_opcode, ParameterPosition::First))
|
addr: self.get_next_address(get_mode(&full_opcode, ParameterPosition::First))
|
||||||
as usize,
|
as usize,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user