2025年1月5日
牛客网-华为题库-合并字符串
详细题目信息参见:
import sys
def fun(c):
"""
对16进制字符进行翻转转换
"""
to2 = format(int(c, 16), "b").rjust(4, "0")
to16 = format(int(to2[::-1], 2), "X")
return to16
while True:
try:
s1, s2 = input().split()
s = list(s1 + s2)
hexs = "0123456789abcdefABCDEF"
# 奇子串排序
s[::2] = sorted(s[::2])
# 偶子串排序
s[1::2] = sorted(s[1::2])
for i in range(len(s)):
if s[i] in hexs:
s[i] = fun(s[i])
print("".join(s))
except:
break