Write a function that compresses an alphanumeric string by collapsing consecutive values. The rules of the compression algorithm are defined by the test cases below.
Each item below has an input value and the expected output from the function.
aaabccccdd
→a3bc4d2
aaaaaffffffffffc
→a5f10c
abcd
→abcd
(note: nota1b1c1d1
)ccceee12eccceee
→c3e4c3e3
(numbers removed)effeac01cb65c
→ef2eac2bc
Try to complete this task within 30 minutes.
- Code structure — specifically how readable and understandable it is
- (Optional) Consider using of whitespace and inline doc strings for clarity
- Git usage — granularity of commits and any branches or tags
- Edge cases — how they're handled so they won't be forgotten
- (Optional) Describe or implement a solution for each case (if any)
- Bonus: Add a very basic test for each case
- Language — use whatever programming language you're most comfortable with
- Number of lines — it can be any length as long as it's readable and understandable
- Time spent — just be honest and tell us how you used the time
- Fork this repo to a public one on your account
- Add an empty file for your code and make a commit
- Make commits as you're working to help show your work
- When you're done submit your fork as a pull request back to this repo
- Send the link to [email protected] with some details about your experience.