a = lambda n:((n+1)&0b11111111) e = lambda n:((n&0b00010101)<<2)|((n&0b10101000)>>2)|((n&0b01000000)<<1)|((n&0b00000010)>>1) u = lambda n:((n+0b11111111)&0b11111111) metaexprs = [[]]*256 for metaindex,exprs in enumerate(metaexprs): exprs = [""]*256 exprs[metaindex] = "w" if metaindex else "z" length = 1 while not all(exprs): for index,expr in enumerate(exprs): if len(expr) == length: candidate_a = a(index) candidate_e = e(index) candidate_u = u(index) if (not exprs[candidate_a]) or (length+1 < len(exprs[candidate_a])): exprs[candidate_a] = expr+"a" if (not exprs[candidate_e]) or (length+1 < len(exprs[candidate_e])): exprs[candidate_e] = expr+"e" if (not exprs[candidate_u]) or (length+1 < len(exprs[candidate_u])): exprs[candidate_u] = expr+"u" length += 1 metaexprs[metaindex] = exprs print("Method 1:") for char in "Hello, world!\r\n": print(metaexprs[0][ord(char)]+"w") print("") print("Method 2:") for prev,curr in zip("\x00Hello, world!\r", "Hello, world!\r\n"): candidate1 = metaexprs[ord(prev)][ord(curr)]+"w" candidate1 = candidate1[1:] if candidate1[0]=="w" else candidate1 candidate2 = metaexprs[0][ord(curr)]+"w" print(sorted([candidate1,candidate2],key=len)[0])