← back to unit
Medium
# puzzle gauntlet medium
Compress the Chant
The crowd chants 'aaabb' — the sports reporter writes 'a3b2'. Build the compressor! 🗜️
You get a chant (lowercase letters). Replace each run of repeated letters with the letter followed by its count (even a count of 1). Print the compressed form.
Example:
Input: chant = "aaabb"
Output: a3b2
"a" repeats 3 times in a row, then "b" repeats 2 times — writing each letter with its run-length gives a3b2.
💡 need a hint?
pg-compress-chant.py🔒 given lines are locked — write your code in between
loading...