Advertisement
Guest User

Untitled

a guest
Jan 10th, 2015
1,143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.17 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3.  
  4. >>> print sum(lat_to_num("​The Instar Emergence"))
  5. 761
  6.  
  7. >>> run_to_lat(num_to_run(lat_to_num("running")))
  8. 'running'
  9.  
  10. >>> print " ".join(["".join(lat_to_run(x)) for x in "​The Instar Emergence".split(" ")])
  11. ᚦᛖ ᛁᚾᛋᛏᚪᚱ ᛖᛗᛖᚱᚷᛖᚾᚳᛖ
  12.  
  13. """
  14.  
  15. gematriaprimus = (
  16.     (u'ᚠ',   'f',   2),
  17.     (u'ᚢ',   'v',   3),
  18.     (u'ᚢ',   'u',   3),
  19.     (u'ᚦ',   'T',   5), # th
  20.     (u'ᚩ',   'o',   7),
  21.     (u'ᚱ',   'r',   11),
  22.     (u'ᚳ',   'c',   13),
  23.     (u'ᚳ',   'k',   13),
  24.     (u'ᚷ',   'g',   17),
  25.     (u'ᚹ',   'w',   19),
  26.     (u'ᚻ',   'h',   23),
  27.     (u'ᚾ',   'n',   29),
  28.     (u'ᛁ',   'i',   31),
  29.     (u'ᛄ',   'j',   37),
  30.     (u'ᛇ',   'E',   41), # eo
  31.     (u'ᛈ',   'p',   43),
  32.     (u'ᛉ',   'x',   47),
  33.     (u'ᛋ',   's',   53),
  34.     (u'ᛋ',   'z',   53),
  35.     (u'ᛏ',   't',   59),
  36.     (u'ᛒ',   'b',   61),
  37.     (u'ᛖ',   'e',   67),
  38.     (u'ᛗ',   'm',   71),
  39.     (u'ᛚ',   'l',   73),
  40.     (u'ᛝ',   'G',   79), # ing
  41.     (u'ᛝ',   'G',   79), # ng
  42.     (u'ᛟ',   'O',   83), # oe
  43.     (u'ᛞ',   'd',   89),
  44.     (u'ᚪ',   'a',   97),
  45.     (u'ᚫ',   'A',  101), # ae
  46.     (u'ᚣ',   'y',  103),
  47.     (u'ᛡ',   'I',  107), # ia
  48.     (u'ᛡ',   'I',  107), # io
  49.     (u'ᛠ',   'X',  109)  # ea
  50. )
  51.  
  52. latsimple = (
  53.     ('T','th'),
  54.     ('E','eo'),
  55.     ('G','ing'),
  56.     ('G','ng'),
  57.     ('O','oe'),
  58.     ('A','ae'),
  59.     ('I','ia'),
  60.     ('I','io'),
  61.     ('X','ea'),
  62. )  
  63.  
  64. def gem_map(x, src, dest):
  65.     m = {p[src]:p[dest] for p in gematriaprimus}
  66.     return [m[c] for c in x if c in m]
  67.  
  68. def lat_to_sim(x):
  69.     for sim in latsimple:
  70.         x = x.replace(sim[1], sim[0])
  71.     return x
  72. def sim_to_lat(x):
  73.     for sim in latsimple:
  74.         x = x.replace(sim[0], sim[1])
  75.     return x
  76.    
  77. def run_to_lat(x):
  78.     return sim_to_lat("".join(gem_map(x, 0, 1)))
  79. def run_to_num(x):
  80.     return gem_map(x, 0, 2)
  81.    
  82. def lat_to_run(x):
  83.     return gem_map(lat_to_sim(x.lower()), 1, 0)
  84. def lat_to_num(x):
  85.     return gem_map(lat_to_sim(x.lower()), 1, 2)
  86.    
  87. def num_to_run(x):
  88.     return gem_map(x, 2, 0)
  89. def num_to_lat(x):
  90.     return sim_to_lat("".join(gem_map(x, 2, 1)))
  91.  
  92. def count(x):
  93.     return sum(lat_to_num(x))
  94. def count_words(x):
  95.     return [sum(lat_to_num(w)) for w in x.split(" ")]
  96. def count_letters(x):
  97.     return [lat_to_num(w) for w in x.split(" ")]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement