题解 | #字符串合并处理#
字符串合并处理
http://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
import sys
for line in sys.stdin:
line = list(line[:-1].replace(' ',''))
line[::2] = sorted(line[::2])
line[1::2] = sorted(line[1::2])
for i in range(len(line)):
if line[i].isdecimal():
line[i] = hex(int(bin(int(line[i]))[2:][::-1]+'0'*(6-len(bin(int(line[i])))),2))[2:].upper()
elif line[i].isalpha() and line[i].upper() < 'G':
line[i] = hex(int(bin(int(line[i].upper(),16))[2:][::-1],2))[2:].upper()
print("".join(line))