题解 | #字符串合并处理#
字符串合并处理
http://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
a=list(input())
a.remove(' ')
b=[]
c=[]
for i in range(len(a)):
if i%2==0:
b[i:]=a[i]
for i in range(len(a)):
if i%2!=0:
c[i:]=a[i]
b.sort()
c.sort()
for i in range(len(b)):
a[i*2]=b[i]
for i in range(len(c)):
a[i*2+1]=c[i]
for i in range(len(a)):
if a[i] in ['a','b','c','d','e','f','A','B','C','D','E','F'] or a[i] in ['1','2','3','4','5','6','7','8','9']:
a[i]=int('0x'+str(a[i]),16)
d1=a[i]//8
d2=(a[i]-d1*8)//4
d3=(a[i]-d1*8-d2*4)//2
d4=a[i]-d1*8-d2*4-d3*2
a[i]=d4*8+d3*4+d2*2+d1
a[i]=hex(a[i])[-1].upper()
a=''.join(a)
print(a)
奇奇怪怪的解题成功∧…∧