题解 | #字符串合并处理#python numberone
字符串合并处理
http://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
python抄作业真香啊
import re
def encrypt(x):
if re.search('[0-9A-Fa-f]',x):
return hex(int(bin(int(x,16))[2:].rjust(4,'0')[::-1],2))[2:].upper()
else:
return x
while True:
try:
a=list(input().replace(" ",""))
a[::2]=sorted(a[::2])
a[1::2]=sorted(a[1::2])
res = ""
for i in a:
res+=encrypt(i)
print(res)
except:
break
