diff --git a/src/bin/day13.rs b/src/bin/day13.rs index 4a83ce7..7fdbd81 100644 --- a/src/bin/day13.rs +++ b/src/bin/day13.rs @@ -24,8 +24,8 @@ impl Pattern { .find(|&x| { let d = min(x + 1, self.map[0].len() - x - 1); - iproduct!(0..self.map.len(), (0..d)) - .filter(|&(y, dx)| self.map[y][x - dx] != self.map[y][x + dx + 1]) + iproduct!(0..self.map.len(), (1..=d)) + .filter(|&(y, dx)| self.map[y][x + 1 - dx] != self.map[y][x + dx]) .count() == allowed_error }) @@ -37,8 +37,8 @@ impl Pattern { .find(|&y| { let d = min(y + 1, self.map.len() - y - 1); - iproduct!(0..self.map[y].len(), (0..d)) - .filter(|&(x, dy)| self.map[y - dy][x] != self.map[y + dy + 1][x]) + iproduct!(0..self.map[y].len(), (1..=d)) + .filter(|&(x, dy)| self.map[y + 1 - dy][x] != self.map[y + dy][x]) .count() == allowed_error })