saahil1292 / fsdse-python-assignment-103

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compress a string such that 'AAABCCDDDD' becomes 'A3BC2D4'. Only compress the string if it saves space.

Constraints

  • Can we assume the string is ASCII?
    • Yes
    • Note: Unicode strings could require special handling depending on your language
  • Is this case sensitive?
    • Yes
  • Can we use additional data structures?
    • Yes
  • Can we assume this fits in memory?
    • Yes

Instructions:

  • Program should be written in file build.py

  • Function name should be compress.

  • Input

     Type:  String
     Value: 'AABBBCDDEEEE'
    
  • Expected Output

      Type:  String
      Value: 'A2B3CD2E4'
    

About


Languages

Language:Python 100.0%