mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
Add more intelligent limits to the playing field.
This commit is contained in:
2
2018/inputs/22.txt
Normal file
2
2018/inputs/22.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
depth: 8103
|
||||
target: 9,758
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user