Solved LeetCode program · 38 of 1,000
#0038 · Count and Say
Original English source
The current is empty text. Place "1" into current.
The built is empty text. The position is 0. The limit is the last position of current. The previous is character 0 of current. The run is 0.
Repeat while position is at most limit.
The symbol is character position of current. If symbol is previous, add 1 to run. If symbol is not previous, Place the character for run into built, Place previous into built, set run to 1, set previous to symbol. Add 1 to position.
Place the character for run into built. Place previous into built. Set current to built.
Set built to empty text. Set position to 0. Set limit to the last position of current. Set previous to character 0 of current. Set run to 0.
Repeat while position is at most limit.
The symbol is character position of current. If symbol is previous, add 1 to run. If symbol is not previous, Place the character for run into built, Place previous into built, set run to 1, set previous to symbol. Add 1 to position.
Place the character for run into built. Place previous into built. Set current to built.
Set built to empty text. Set position to 0. Set limit to the last position of current. Set previous to character 0 of current. Set run to 0.
Repeat while position is at most limit.
The symbol is character position of current. If symbol is previous, add 1 to run. If symbol is not previous, Place the character for run into built, Place previous into built, set run to 1, set previous to symbol. Add 1 to position.
Place the character for run into built. Place previous into built. Set current to built.
Report current.
Expected stdout
1211