This commit is contained in:
kageru 2019-12-19 07:24:09 +01:00
parent 26a9254d73
commit 6f66112fc9
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
6 changed files with 6059 additions and 1 deletions

11
2019/19/Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "day19"
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" }
grid = { path = "../grid" }

1
2019/19/input Normal file
View File

@ -0,0 +1 @@
109,424,203,1,21101,0,11,0,1105,1,282,21101,18,0,0,1105,1,259,1202,1,1,221,203,1,21102,1,31,0,1106,0,282,21102,38,1,0,1106,0,259,21002,23,1,2,22102,1,1,3,21102,1,1,1,21102,1,57,0,1105,1,303,2102,1,1,222,20101,0,221,3,21001,221,0,2,21102,259,1,1,21102,1,80,0,1106,0,225,21102,62,1,2,21101,91,0,0,1105,1,303,2101,0,1,223,21001,222,0,4,21101,0,259,3,21101,0,225,2,21101,0,225,1,21101,0,118,0,1105,1,225,20102,1,222,3,21101,94,0,2,21102,133,1,0,1105,1,303,21202,1,-1,1,22001,223,1,1,21101,0,148,0,1105,1,259,1202,1,1,223,20101,0,221,4,21001,222,0,3,21102,17,1,2,1001,132,-2,224,1002,224,2,224,1001,224,3,224,1002,132,-1,132,1,224,132,224,21001,224,1,1,21101,195,0,0,105,1,109,20207,1,223,2,20101,0,23,1,21102,-1,1,3,21101,214,0,0,1106,0,303,22101,1,1,1,204,1,99,0,0,0,0,109,5,2101,0,-4,249,22102,1,-3,1,22101,0,-2,2,21201,-1,0,3,21102,1,250,0,1106,0,225,22101,0,1,-4,109,-5,2105,1,0,109,3,22107,0,-2,-1,21202,-1,2,-1,21201,-1,-1,-1,22202,-1,-2,-2,109,-3,2106,0,0,109,3,21207,-2,0,-1,1206,-1,294,104,0,99,22101,0,-2,-2,109,-3,2106,0,0,109,5,22207,-3,-4,-1,1206,-1,346,22201,-4,-3,-4,21202,-3,-1,-1,22201,-4,-1,2,21202,2,-1,-1,22201,-4,-1,1,21201,-2,0,3,21101,343,0,0,1106,0,303,1105,1,415,22207,-2,-3,-1,1206,-1,387,22201,-3,-2,-3,21202,-2,-1,-1,22201,-3,-1,3,21202,3,-1,-1,22201,-3,-1,2,22102,1,-4,1,21102,384,1,0,1105,1,303,1105,1,415,21202,-4,-1,-4,22201,-4,-3,-4,22202,-3,-2,-2,22202,-2,-4,-4,22202,-3,-2,-3,21202,-4,-1,-2,22201,-3,-2,1,21201,1,0,-4,109,-5,2105,1,0

1
2019/19/notes Normal file
View File

@ -0,0 +1 @@
7690958 too low

6004
2019/19/output2 Normal file

File diff suppressed because it is too large Load Diff

41
2019/19/src/main.rs Normal file
View File

@ -0,0 +1,41 @@
use intcode::*;
use grid::*;
use std::collections::HashMap;
fn tractor_at_position(input: &Vec<i64>, x: i64, y: i64) -> bool {
IntComputer::new(input.clone(), 0, vec![x, y]).get_all_outputs()[0] == 1
}
const ZONE_SIZE: i64 = 100;
fn main() {
let input = read_input();
let mut s = 0;
for x in 0..50 {
for y in 0..50 {
if tractor_at_position(&input, x, y) {
s += 1;
}
}
}
println!("Part 1: {}", s);
let mut beam = HashMap::new();
for x in 0..900 {
for y in 0..1100 {
let here = tractor_at_position(&input, x, y);
beam.insert(Position2D {x, y}, if here { '#'} else { '.' });
if here
&& tractor_at_position(&input, x+ZONE_SIZE, y)
&& tractor_at_position(&input, x, y+ZONE_SIZE)
&& tractor_at_position(&input, x+ZONE_SIZE, y+ZONE_SIZE) {
beam.insert(Position2D {x, y}, 'O');
println!("Part 2: {}, {}, {}", x, y, x*10_000 + y);
}
}
if x%100 == 0 {
println!("Outer loop {}", x);
}
}
println!("{}", draw_ascii(&beam, '.'));
}

View File

@ -189,7 +189,7 @@ impl IntComputer {
first,
second,
addr,
} => self.tape[addr as usize] = (first < second) as i64,
} => safe_write(&mut self.tape, addr as usize, (first < second) as i64),
Operation::Equals {
first,
second,