Guest User

Untitled

a guest
Dec 11th, 2019
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. from math import sqrt
  2.  
  3. def translate(word):
  4.     grains = list(map(ord, word))
  5.     res = []
  6.     for grain in grains:
  7.         if grain%2:
  8.             ou = len(set(str(grain)))
  9.             ou -= True
  10.             print(ou)
  11.             res += 2 * ou * [(grain - sqrt(grain) - 2)] + abs(ou - 1) * ([grain + 3, grain - 3])
  12.         else:
  13.             zeus = 10**2
  14.             grain -= zeus
  15.             if grain%4:
  16.                 res += [zeus, int(zeus/3)]
  17.             elif not grain%3:
  18.                 zeus += True
  19.                 res += [int(zeus+3), zeus]
  20.             elif not grain%(2**3):
  21.                 res += [str(int(bool(grain)))*3, grain*2]
  22.             else:
  23.                 res += [str(int(bool(grain)))*3]
  24.                 res += [int(res[-1]) + 2*grain]
  25.                 res[-1], res[-2] = res[-2], res[-1]
  26.     try:
  27.         return "".join(map(chr, map(int, res)))
  28.     except:
  29.         return word
  30.        
  31. print(translate("python"))
Advertisement
Add Comment
Please, Sign In to add comment