Advertisement
Guest User

ambigram.py

a guest
Oct 30th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. R=dict(a='eD',b='q',d='pP',h='y',l='l',m='w',n='uU',o='oOGQ',s='sS',t='t',x='xX',z='zZ',A='vV',B='E',D='G',H='H',I='I',M='W',N='N')
  2. V='ijlmnotuvwxyAHIMOQTUVWXY'
  3. W=dict(b='d',p='q',s='z',B='E',G='D',S='Z')
  4. H='lotxBCDEHIKOX'
  5. T='AHIMOTUVWXYilmnotuvwxy'
  6. s=raw_input()
  7. r=v=h=t=1
  8. for i,j in R.items():
  9.  for c in j:R[c]=R.get(c,'')+i
  10. for i,j in W.items():
  11.  for c in j:W[c]=W.get(c,'')+i
  12. for i in range(len(s)):
  13.  c,l=s[i],s[-i-1]
  14.  r&=(c in R)+(l in R[c])>1
  15.  v&=(c in V)+(l in V)>1
  16.  h&=(c in H)+(l in H)>1
  17.  t&=c in T
  18. print'R'*r+'V'*v+'H'*h+'T'*t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement