Add more intelligent limits to the playing field.

This commit is contained in:
2018-12-22 08:29:39 +01:00
parent 655ce5af18
commit a202faa7b5
2 changed files with 5 additions and 3 deletions

2
2018/inputs/22.txt Normal file
View File

@@ -0,0 +1,2 @@
depth: 8103
target: 9,758

View File

@@ -99,7 +99,7 @@ impl Solution for Day22 {
fn part2(&mut self, input: &mut Read) -> String {
let (depth, target) = read_input(input);
let mut table = compute_table((1000, 1000), depth);
let mut table = compute_table((target.0 + 100, target.1 + 100), depth);
table[target.1][target.0] = 0;
let mut todo = BinaryHeap::new();
@@ -137,8 +137,8 @@ impl Solution for Day22 {
let xmin = if x == 0 { 0 } else { x - 1 };
let ymin = if y == 0 { 0 } else { y - 1 };
for xn in xmin..=(x + 1) {
for yn in ymin..=(y + 1) {
for xn in xmin..=(x + 1).min(target.0 + 100) {
for yn in ymin..=(y + 1).min(target.1 + 100) {
let new_state = State {
pos: (xn, yn),
torch: state.torch,