The TransCompilator

Solved LeetCode program · 325 of 1,000

#0443 · String Compression

Medium String chunk-07.md

Original English source

Keep a shared chars holding "a", "a", "b", "b", "c", "c", and "c". Keep a shared symbol as empty text. Keep a shared run of 0.
To count from spot (a whole number) with next (a whole number). If next is more than 6, return. If item next of chars matches symbol, add 1 to run, count from spot with next plus 1.

The result is empty text. The spot is 0.
Repeat while spot is at most 6.
Set symbol to item spot of chars. Set run to 1. Count from spot with spot plus 1. Place symbol into result. If run is more than 1, Place format whole number run as text into result. Add run to spot.

The lastresult is the last position of result. The size is lastresult plus 1. Show size.

Open in Playground Browse all 1,000 problems

Expected stdout

6