题解 | #字符串合并处理#
字符串合并处理
https://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
while 1: try: s0 = input().split() s1 = s0[0] s2 = s0[1] s = s1 + s2 s_new = '' s_trans = '' se = s[0:len(s):2] so = s[1:len(s):2] se = sorted(se) so = sorted(so) for i in range(len(se)): if len(s) % 2 != 0 and i == len(se) - 1: s_new = s_new + se[i] break s_new = s_new + se[i] + so[i] for c in s_new: if ord(c) in range(ord('0'), ord('9') + 1) or ord(c) in range(ord('a'), ord('f') + 1) or ord(c) in range(ord('A'), ord('F') + 1): s_trans += hex(int((bin(int(c, 16))[2:].zfill(4))[::-1], 2)).upper()[2:] else: s_trans += c print(s_trans) except: break