D19 done. too tilted not to brute force
This commit is contained in:
parent
6f66112fc9
commit
f4017dd12a
|
@ -8,4 +8,3 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
intcode = { path = "../intcode" }
|
intcode = { path = "../intcode" }
|
||||||
grid = { path = "../grid" }
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
7690958 too low
|
|
|
@ -1,12 +1,10 @@
|
||||||
use intcode::*;
|
use intcode::*;
|
||||||
use grid::*;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
fn tractor_at_position(input: &Vec<i64>, x: i64, y: i64) -> bool {
|
fn tractor_at_position(input: &[i64], x: i64, y: i64) -> bool {
|
||||||
IntComputer::new(input.clone(), 0, vec![x, y]).get_all_outputs()[0] == 1
|
IntComputer::new(input.to_vec(), 0, vec![x, y]).get_all_outputs()[0] == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
const ZONE_SIZE: i64 = 100;
|
const ZONE_SIZE: i64 = 99;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let input = read_input();
|
let input = read_input();
|
||||||
|
@ -20,22 +18,18 @@ fn main() {
|
||||||
}
|
}
|
||||||
println!("Part 1: {}", s);
|
println!("Part 1: {}", s);
|
||||||
|
|
||||||
let mut beam = HashMap::new();
|
for y in 0..1000 {
|
||||||
for x in 0..900 {
|
for x in 0..1000 {
|
||||||
for y in 0..1100 {
|
if tractor_at_position(&input, x, y)
|
||||||
let here = tractor_at_position(&input, x, y);
|
&& tractor_at_position(&input, x + ZONE_SIZE, y)
|
||||||
beam.insert(Position2D {x, y}, if here { '#'} else { '.' });
|
&& tractor_at_position(&input, x, y + ZONE_SIZE)
|
||||||
if here
|
{
|
||||||
&& tractor_at_position(&input, x+ZONE_SIZE, y)
|
println!("Part 2: {}", y * 10_000 + x);
|
||||||
&& tractor_at_position(&input, x, y+ZONE_SIZE)
|
return;
|
||||||
&& 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 {
|
if y % 100 == 0 {
|
||||||
println!("Outer loop {}", x);
|
println!("Outer loop {}", y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("{}", draw_ascii(&beam, '.'));
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user