How to Permute the positions of the last two nibbles of a number. In other words, a block
1
Expert's answer
2016-02-25T00:00:54-0500
x=int(input()) x=list(bin(x)[2:])
x_change=[] x_finish=[]
if len(x)<8 : x_change = [ '0' for i in range (8-len(x))] for i in range(len(x)): x_change.append(x[i]) else : x_change=x
if len(x_change)==8 : for i in range(4,8): x_finish.append(x_change[i]) for i in range(4): x_finish.append(x_change[i]) else: for i in range(len(x_change)-8): x_finish.append(x_change[i]) for i in range(len(x_change)-4,len(x_change)): x_finish.append(x_change[i]) for i in range(len(x_change)-8,len(x_change)-4): x_finish.append(x_change[i])
Comments
Leave a comment