字符串合并处理
字符串合并处理
http://www.nowcoder.com/questionTerminal/d3d8e23870584782b3dd48f26cb39c8f
def bu(s): if len(s)<4: for i in range(4-len(s)):s="0"+s return s else:return s def change(s): if s.isdigit() or 65<=ord(s)<=70 or 97<=ord(s)<=102: return hex(int("".join([i for i in bu(bin(int(s,16))[2:])][::-1]),2))[2:].upper() else: return s while True: try: n="".join(input().split()) l,ll=[],[] for i in range(len(n)): if i%2==0 :l+=[n[i]] else:ll+=[n[i]] l.sort() ln=len(l) ll.sort() for i in range(len(l)-1): l.insert(2*i+1,ll[i]) if ln==len(ll):l.append(ll[-1]) for i in range(len(l)): l[i]=change(l[i]) print("".join(l)) except: break