This question evaluates proficiency in bitmap and matrix manipulation, lossless compression/decompression techniques, and modular code reuse for transformations such as inversion, targeting skills in data representation, algorithmic correctness, and space-time trade-offs.
You are given a bitmap lookup table (a dictionary/map) that represents a tiny “font”.
'J'
)
0/1
integers where:
0
= background pixel
1
= foreground pixel
Example bitmap for the letter J (10 rows × 6 columns):
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
1 0 0 0 1 0
0 1 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Implement a function that, given the lookup table and an input character, prints the character’s bitmap to the console in the same grid format (preserve rows/columns).
To save space, implement:
compress(bitmap)
: Convert a 2D
0/1
matrix into a more compact representation.
decompress(compressed)
: Restore the original 2D matrix.
Requirements:
Notes:
1
s, etc.), but it must support lossless round-trip.
Perform an additional transformation on the bitmap(s), then print the result.
0
and
1
).
0/1
separated by spaces (or equivalent consistent formatting).