All problems

Paper lace previews reverse the pattern within each packed byte

Level 1 · node · Data · Incorrect MSB-first reading order in packed bitmap rows

Scenario

A fictional paper lace workshop stores hole patterns as packed bits, one row at a time. Empty and completely filled rows look correct in previews, but asymmetric patterns appear reversed in groups of eight cells. Review the row decoder and the pattern preview entry point.

Requirements

preview(rows, width) receives each row as a byte array and returns arrays of zeros or ones in input row order. Each byte is an integer from 0 to 255. Cells are stored from left to right, starting at the most significant bit (bit 7) and ending at the least significant bit (bit 0). width is a nonnegative integer and every row has enough bytes. Read exactly width cells per row and ignore unused bits in the final byte. Do not mutate the input.

Acceptance criteria

  • Correctly decode empty patterns and completely filled rows.
  • Return the cells of asymmetric bytes in the left-to-right order required by the storage format.
  • Decode rows spanning multiple bytes and omit unused bits in the final byte.
  • Handle zero width while preserving input row order and original data.