Python 2, (削除) 151 (削除ここまで) 147(削除) 147 (削除ここまで) 135 bytes
d,D,i=[]D=[],[],0
for c in input():
if'/'<c<':':x=[c];d+=[x];D+=[x]x=[[c]];d=x+d;D+=x
else:x=d[-1];x+=c
if leny=d[0];y+=c;d=d[len(xy)>int(x[0]y[0]):d.pop()]
print''.join(''.join(w)for w in D)
Explanation:
The code keeps two lists of constituent groups, d and D.
Each character of the string is then scanned:
- If it is a digit, a new group is added to both lists
- Otherwise, the character is added to the lastlatest group in
d
When a group has the same length as its digit, the group is removed from d.
At the end, the D is concatenated, as the groups in D are in the original order.
Example:
Input = '111xyz''1121xwyzv'
d = [], D = []
Loop each character in the input
c='1'
d=[[1]], D=[[1]]
c='1'
d=[[1], [1]], D=[[1], [1]]
c='2'
d=[[2], [1], [1]], D=[[1], [1], [2]]
c='1'
d=[[1], [2], [1], [1]], D=[[1], [1], [2], [1]]
c='x'
d=[[1]d=[[1x], [2], [1], [1x]][1]], D=[[1], [1], [2], [1x]]
lastlatest group in d is full:
d=[[1]d=[[2], [1], [1]], D=[[1], [1], [2], [1x]]
c='w'
d=[[2w], [1], [1]], D=[[1], [1], [2w], [1x]]
c='y'
d=[[1]d=[[2wy], [1y]][1], [1]], D=[[1], [1y][1], [2wy], [1x]]
lastlatest group in d is full:
d=[[1]], D=[[1], [1y][1], [2wy], [1x]]
c='z'
d=[[1z]]d=[[1z], D=[[1z][1]], [1y]D=[[1], [1z], [2wy], [1x]]
lastlatest group in d is full:
d=[[1]], D=[[1], [1z], [2wy], [1x]]
c='v'
d=[[1v]], D=[[1v], [1z], [2wy], [1x]]
latest group in d is full:
d=[], D=[[1z]D=[[1v], [1y][1z], [2wy], [1x]]
print D in order:
'1z1y1x''1v1z2wy1x'
Python 2, (削除) 151 (削除ここまで) 147 bytes
d,D,i=[],[],0
for c in input():
if'/'<c<':':x=[c];d+=[x];D+=[x]
else:x=d[-1];x+=c
if len(x)>int(x[0]):d.pop()
print''.join(''.join(w)for w in D)
Explanation:
The code keeps two lists of constituent groups, d and D.
Each character of the string is then scanned:
- If it is a digit, a new group is added to both lists
- Otherwise, the character is added to the last group in
d
When a group has the same length as its digit, the group is removed from d.
At the end, the D is concatenated, as the groups in D are in the original order.
Example:
Input = '111xyz'
d = [], D = []
Loop each character in the input
c='1'
d=[[1]], D=[[1]]
c='1'
d=[[1], [1]], D=[[1], [1]]
c='1'
d=[[1], [1], [1]], D=[[1], [1], [1]]
c='x'
d=[[1], [1], [1x]], D=[[1], [1], [1x]]
last group in d is full:
d=[[1], [1]], D=[[1], [1], [1x]]
c='y'
d=[[1], [1y]], D=[[1], [1y], [1x]]
last group in d is full:
d=[[1]], D=[[1], [1y], [1x]]
c='z'
d=[[1z]], D=[[1z], [1y], [1x]]
last group in d is full:
d=[], D=[[1z], [1y], [1x]]
print D in order:
'1z1y1x'
Python 2, (削除) 151 (削除ここまで) (削除) 147 (削除ここまで) 135 bytes
d,D=[],[]
for c in input():
if'/'<c<':':x=[[c]];d=x+d;D+=x
else:y=d[0];y+=c;d=d[len(y)>int(y[0]):]
print''.join(''.join(w)for w in D)
Explanation:
The code keeps two lists of constituent groups, d and D.
Each character of the string is then scanned:
- If it is a digit, a new group is added to both lists
- Otherwise, the character is added to the latest group in
d
When a group has the same length as its digit, the group is removed from d.
At the end, the D is concatenated, as the groups in D are in the original order.
Example:
Input = '1121xwyzv'
d = [], D = []
Loop each character in the input
c='1'
d=[[1]], D=[[1]]
c='1'
d=[[1], [1]], D=[[1], [1]]
c='2'
d=[[2], [1], [1]], D=[[1], [1], [2]]
c='1'
d=[[1], [2], [1], [1]], D=[[1], [1], [2], [1]]
c='x'
d=[[1x], [2], [1], [1]], D=[[1], [1], [2], [1x]]
latest group in d is full:
d=[[2], [1], [1]], D=[[1], [1], [2], [1x]]
c='w'
d=[[2w], [1], [1]], D=[[1], [1], [2w], [1x]]
c='y'
d=[[2wy], [1], [1]], D=[[1], [1], [2wy], [1x]]
latest group in d is full:
d=[[1]], D=[[1], [1], [2wy], [1x]]
c='z'
d=[[1z], [1]], D=[[1], [1z], [2wy], [1x]]
latest group in d is full:
d=[[1]], D=[[1], [1z], [2wy], [1x]]
c='v'
d=[[1v]], D=[[1v], [1z], [2wy], [1x]]
latest group in d is full:
d=[], D=[[1v], [1z], [2wy], [1x]]
print D in order:
'1v1z2wy1x'
Python 2, 151(削除) 151 (削除ここまで) 147 bytes
s=input()
d,D,i=[],[],0
for c in sinput():
if'/'<c<':':x=[c];d+=[x];D+=[x]
else:x=d[-1];x+=c
if len(x)>int(x[0]):d.pop()
print''.join(''.join(w)for w in D)
Explanation:
The code keeps two lists of constituent groups, d and D.
Each character of the string is then scanned:
- If it is a digit, a new group is added to both lists
- Otherwise, the character is added to the last group in
d
When a group has the same length as its digit, the group is removed from d.
At the end, the D is concatenated, as the groups in D are in the original order.
Example:
Input = '111xyz'
d = [], D = []
Loop each character in the input
c='1'
d=[[1]], D=[[1]]
c='1'
d=[[1], [1]], D=[[1], [1]]
c='1'
d=[[1], [1], [1]], D=[[1], [1], [1]]
c='x'
d=[[1], [1], [1x]], D=[[1], [1], [1x]]
last group in d is full:
d=[[1], [1]], D=[[1], [1], [1x]]
c='y'
d=[[1], [1y]], D=[[1], [1y], [1x]]
last group in d is full:
d=[[1]], D=[[1], [1y], [1x]]
c='z'
d=[[1z]], D=[[1z], [1y], [1x]]
last group in d is full:
d=[], D=[[1z], [1y], [1x]]
print D in order:
'1z1y1x'
Python 2, 151 bytes
s=input()
d,D,i=[],[],0
for c in s:
if'/'<c<':':x=[c];d+=[x];D+=[x]
else:x=d[-1];x+=c
if len(x)>int(x[0]):d.pop()
print''.join(''.join(w)for w in D)
Python 2, (削除) 151 (削除ここまで) 147 bytes
d,D,i=[],[],0
for c in input():
if'/'<c<':':x=[c];d+=[x];D+=[x]
else:x=d[-1];x+=c
if len(x)>int(x[0]):d.pop()
print''.join(''.join(w)for w in D)
Explanation:
The code keeps two lists of constituent groups, d and D.
Each character of the string is then scanned:
- If it is a digit, a new group is added to both lists
- Otherwise, the character is added to the last group in
d
When a group has the same length as its digit, the group is removed from d.
At the end, the D is concatenated, as the groups in D are in the original order.
Example:
Input = '111xyz'
d = [], D = []
Loop each character in the input
c='1'
d=[[1]], D=[[1]]
c='1'
d=[[1], [1]], D=[[1], [1]]
c='1'
d=[[1], [1], [1]], D=[[1], [1], [1]]
c='x'
d=[[1], [1], [1x]], D=[[1], [1], [1x]]
last group in d is full:
d=[[1], [1]], D=[[1], [1], [1x]]
c='y'
d=[[1], [1y]], D=[[1], [1y], [1x]]
last group in d is full:
d=[[1]], D=[[1], [1y], [1x]]
c='z'
d=[[1z]], D=[[1z], [1y], [1x]]
last group in d is full:
d=[], D=[[1z], [1y], [1x]]
print D in order:
'1z1y1x'