text: "aaabba -> a3b2a1 のように文字列を圧縮するスクリプト"
  
  
  def compression(str1):
      list_str = list(str1)
      compression_str = []
      i = 0
      while i < len(str1):
          cnt = 1
          j = i
          compression_str.append(str1[i])
          
          if j == len(str1)-1:
              compression_str.append(str(cnt))
              break
          while (list_str[j] == list_str[j+1]):
              cnt += 1
              j += 1
          
          compression_str.append(str(cnt))
          i += cnt-1
          i += 1
      compression_str = ''.join(compression_str)
  
      if len(compression_str) > len(str1):
          return str1
      else:
          return compression_str
  
  print(compression("aaabba"))
  print(compression("abcdef"))