Advertisement
imk0tter

Imk0tter

Nov 19th, 2010
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def alien(number,source,target): return __alien(_alien(number,source,len(number)),target)
  2.    
  3. def _alien(num,b1,l,mod=0):
  4.     out = b1.index(num[l-1])*len(b1)**mod
  5.     return out if l == 1 else out + _alien(num,b1,l-1,mod+1)
  6.        
  7. def __alien(num,b2):
  8.     charset = b2
  9.     l = len(b2)
  10.     y = num%l
  11.     out = charset[y]
  12.     return out if num == y else __alien((num-y)/l,b2) + out
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement