题解 | #字符串合并处理#
字符串合并处理
http://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
```numto = {}
numto["1"] = ["8"]
numto["2"] = ["4"]
numto["3"] = ["C"]
numto["4"] = ["2"]
numto["5"] = ["A"]
numto["6"] = ["6"]
numto["7"] = ["E"]
numto["8"] = ["1"]
numto["9"] = ["9"]
numto["A"] = ["5"]
numto["B"] = ["D"]
numto["C"] = ["3"]
numto["D"] = ["B"]
numto["E"] = ["7"]
numto["F"] = ["F"]
numto["a"] = ["5"]
numto["b"] = ["D"]
numto["c"] = ["3"]
numto["d"] = ["B"]
numto["e"] = ["7"]
numto["f"] = ["F"]
while True:
try:
a =input()
b = a.split(" ")
c = b[0]+b[1]
num = len(c)
c1 = []
c2 = []
for i in range(num):
if i % 2 == 0:
c1.append(c[i])
else:
c2.append(c[i])
c1.sort()
c2.sort()
new_a = []
count = 0
count1 = 0
for j in range(num):
if j % 2 == 0:
new_a.append(c1[count])
else:
new_a.append(c2[count])
count = count + 1
new_b = []
for k in range(num):
try:
new_b += numto[new_a[k]]
except:
new_b += new_a[k]
bbb = ''
bbb = bbb.join(new_b)
print(bbb)
except:
break