题解 | #字符串合并处理#
字符串合并处理
http://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
def step_1(a,b):#第一步操作
c=str(a)+str(b)
return c
def step_2(a):#第二步操作
odd=[]
even=[]
for i in range(len(a)):
if i%2 == 0:
even.append(a[i])
else:
odd.append(a[i])
odd=sorted(odd)
even=sorted(even)
b=[]
for i in range(len(a)):
if i%2 ==0:
j=int(i/2)
b.append(even[j])
else:
j=int((i-1)/2)
b.append(odd[j])
c=''.join(b)
return str(c)
def step_3(a):#第三步操作
dic=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
f=''
for i in a:
if i.isdigit() :
b=bin(int(i))[2:].zfill(4)
c=b[::-1]
d=int(c,2)
e=dic[d]
f+=str(e)
elif i.isalpha() and i.upper() in dic:
for j in range(len(dic)):
if dic[j]==i.upper():
b=bin(j)[2:].zfill(4)
break
c=b[::-1]
d=int(c,2)
e=dic[d]
f+=str(e)
else:
f+=str(i)
return f
str_1,str_2=input().split()
str_3=step_1(str_1,str_2)
str_4=step_2(str_3)
str_5=step_3(str_4)
print(str_5)