1
0
Fork 0

day(12): shift the difference by one

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-12-13 21:38:54 +01:00
parent 327a2d1df4
commit a41963a338
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -24,8 +24,8 @@ impl Pattern {
.find(|&x| { .find(|&x| {
let d = min(x + 1, self.map[0].len() - x - 1); let d = min(x + 1, self.map[0].len() - x - 1);
iproduct!(0..self.map.len(), (0..d)) iproduct!(0..self.map.len(), (1..=d))
.filter(|&(y, dx)| self.map[y][x - dx] != self.map[y][x + dx + 1]) .filter(|&(y, dx)| self.map[y][x + 1 - dx] != self.map[y][x + dx])
.count() .count()
== allowed_error == allowed_error
}) })
@ -37,8 +37,8 @@ impl Pattern {
.find(|&y| { .find(|&y| {
let d = min(y + 1, self.map.len() - y - 1); let d = min(y + 1, self.map.len() - y - 1);
iproduct!(0..self.map[y].len(), (0..d)) iproduct!(0..self.map[y].len(), (1..=d))
.filter(|&(x, dy)| self.map[y - dy][x] != self.map[y + dy + 1][x]) .filter(|&(x, dy)| self.map[y + 1 - dy][x] != self.map[y + dy][x])
.count() .count()
== allowed_error == allowed_error
}) })