Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
9-liner, speedy solution in Speedy category for Cipher Dict by tamagoyaki
def get_cipher(plain):
empdic,up = [(dic:={})],True
for i,c in enumerate((arr:=[-1]+[int(c) for c in str(int(plain.encode().hex(),16))])[1:]):
if ((c<=arr[i])*up) or ((not up)*(c>=arr[i])):
up = not(up)
empdic.pop(0)
empdic[0][c] = {}
empdic.append(empdic[0][c])
return dic
May 2, 2024
Comments: