~cdv/aoc-2020

e4cf14fe1cceb4488cacfdb469f829fb3194f597 — Chris Vittal 3 years ago 69692f0 main
rs: avoid panic in day 20 (debug mode only, release is fine)
1 files changed, 3 insertions(+), 1 deletions(-)

M rs/src/day20.rs
M rs/src/day20.rs => rs/src/day20.rs +3 -1
@@ 94,7 94,9 @@ impl Tile {
    fn matching(&self, side: usize) -> u16 {
        let d = self.data.rows;
        let s = self.nesw[side];
        let r = (0..d).fold(0, |a, b| (a << 1) | (((s & (1 << b)) != 0) as u16));
        let r = (0..d).fold(0u16, |a, b| {
            a.wrapping_shl(1) | ((s & (1u16.wrapping_shl(b as u32)) != 0) as u16)
        });
        r
    }