day 17 task 2 for my input only

This commit is contained in:
Johannes
2019-12-25 22:26:36 +01:00
parent d590b1ad1a
commit a5019f1afb

View File

@@ -9,6 +9,7 @@ pub fn run() {
.collect(); .collect();
task1(input.clone()); task1(input.clone());
task2(input.clone());
} }
fn task1(ram: RAM) { fn task1(ram: RAM) {
@@ -43,6 +44,25 @@ fn task1(ram: RAM) {
println!("Task 1: sum of alignment parameters is {}", alignment_sum); println!("Task 1: sum of alignment parameters is {}", alignment_sum);
} }
fn task2(mut ram: RAM) {
// R,8,L,10,R,8,R,12,R,8,L,8,12,R,8,L,10,R,8,L,12,L,10,L,8,R,8,L,10,R,8,R,12,R,8,L,8,L,12,L,12,L,10,L,8,L,12,L,10,L,8,R,8,L,10,R,8,R,12,R,8,L,8,L,12
/*
R,8,L,10,R,8
R,12,R,8,L,8,L,12
L,12,L,10,L,8
*/
let main = "A,B,A,C,A,B,C,C,A,B";
let a = "R,8,L,10,R,8";
let b = "R,12,R,8,L,8,L,12";
let c = "L,12,L,10,L,8";
let program = format!("{}\n{}\n{}\n{}\nn\n", main, a, b, c);
ram.insert(0, 2);
let mut pc = IntCodeComputer::new(program.chars().map(|it| (it as u8) as i128).collect(), ram);
pc.run_until_end();
let out = pc.get_output();
println!("{:?}", out.last().unwrap());
}
struct Pos(usize, usize); struct Pos(usize, usize);
impl Pos { impl Pos {