ludus

Data Compression

ld-0006 · 3 › ███░░░░░░░ · text, arrays · requires: arrays · oner lambdaless golfed

Your client regularly works with large files, but their system cannot store them properly due to their size. Help reduce the space each file takes by using Run Length Encoding.

Consider the string "aaaabbbccccc" — a sequence of four a's, three b's, and five c's. Its encoding is each letter followed by how many there are in the run: "a4b3c5". Runs of one still get their count: "abc" encodes to "a1b1c1".

Each input row holds one file (lowercase letters only). Produce its encoding in the same row of OUTPUT. The grader swaps in file lists of different lengths, so cover the whole OUTPUT range: empty input rows must produce empty output rows.

Work on it

  1. Make a copy of the template — it becomes your private sheet.
  2. Solve it however you like — helper columns and extra tabs are fair game. The one rule: the grader swaps INPUT for other datasets, so never put your own content inside INPUT.
  3. Check yourself against the expected sample output shown in your copy (and below).
  4. Submit below — Share → "anyone with the link, Viewer", paste the link. Your sheet is graded against 2 hidden datasets, so hardcoded answers won't survive.

Sample

Input (Input!B2:B18)

Data
aaaabbbccccc
abc
z
aaaaaaaaaaaa
aabbaabb

Expected output (Answer!B3:B18)

Encoded
a4b3c5
a1b1c1
z1
a12
a2b2a2b2

Adapted from "Data Compression" in the astral.cafe Community Practice Problems sheet.