对于字符串中连续的M个相同字符串S将会压缩为M|S,例如字符串ABCABCABC将会压缩为[3|ABC],现在接收一段字符串,对其进行解压缩。
输入描述:
输入第一行包含一个字符串s,代表压缩后的字符串。
s的长度<=1000;
s仅包含大写字母、[、|、];
解压后的字符串长度不超过100000;
输出描述
输出一个字符串,代表解压后的字符串。
示例:输入HG[3|B[2|CA]]F
输出HGBCACABCACABCACAF
def get_v(s):
return s[3:-1] *int(s[1])
if __name__ == "__main__":
strs = str(raw_input())
stack = ""
for index,item in enumerate(strs):
stack +=item
if item=="]":
s1 = stack[stack.rindex("["):]
pre = stack[:stack.rindex("[")]
stack = pre +get_v(s1)
print stack