题解 | #字符串合并处理#
字符串合并处理
https://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
def rev(i): if i in '0123456789ABCDEFabcdef': bin_result = bin(int(i,16))[2:].rjust(4,'0')[::-1] decimal_val = int(bin_result, 2) hex_val = hex(decimal_val)[2:].upper() return hex_val else: return i str1, str2 = input().split() s = list(str1+str2) s[::2] = sorted(s[::2]) s[1::2] = sorted(s[1::2]) result = '' for i in s: result += rev(i) print(result)