Module aoc::year2019::day08

source ·
Expand description

§Space Image Format

Functions§

  • Each layer is 25 * 6 = 150 bytes and there are 100 layers total. It’s faster to count pixels 8 at a time by parsing the bytes as u64 then using bitwise logic and the count_ones intrinsic. The only minor wrinkle is that 8 does not divide 150 evenly so we must handle the last 6 bytes specially.
  • Since a black or white pixel covers those in lower layers, it’s faster to check each pixel stopping as soon as we hit a non-transparent value.