Untitled

a guest
Nov 29th, 2013
690
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. gem3 = (
2.     (79, ("ING")),
3. )
4.
5. gem2 = (
6.     (5, ("TH")),
7.     (41, ("EO")),
8.     (79, ("NG")),
9.     (83, ("OE")),
10.     (101, ("AE")),
11.     (107, ("IA", "IO")),
12.     (109, ("EA")),
13. )
14.
15. gem = (
16.     (2, ("F")),
17.     (3, ("U", "V")),
18.     (7, ("O")),
19.     (11, ("R")),
20.     (13, ("C", "K")),
21.     (17, ("G")),
22.     (19, ("W")),
23.     (23, ("H")),
24.     (29, ("N")),
25.     (31, ("I")),
26.     (37, ("J")),
27.     (43, ("P")),
28.     (47, ("X")),
29.     (53, ("S", "Z")),
30.     (59, ("T")),
31.     (61, ("B")),
32.     (67, ("E")),
33.     (71, ("M")),
34.     (73, ("L")),
35.     (89, ("D")),
36.     (97, ("A")),
37.     (103, ("Y")),
38. )
39.
40. def enc_2(c, arr):
41.     for g in arr:
42.         if c.upper() in g[1]:
43.             return g[0]
44.
45. def enc(s):
46.     sum = 0
47.
48.     i = 0
49.     while i < len(s):
50.         if i < len(s) - 2:
51.             c = s[i] + s[i + 1] + s[i + 2]
52.             o = enc_2(c, gem3)
53.             if o > 0:
54.                 print("{0}, {1}".format(c, o))
55.                 sum += o
56.                 i += 3
57.                 continue
58.
59.         if i < len(s) - 1:
60.             c = s[i] + s[i + 1]
61.             o = enc_2(c, gem2)
62.             if o > 0:
63.                 print("{0}, {1}".format(c, o))
64.                 sum += o
65.                 i += 2
66.                 continue
67.
68.         o = enc_2(s[i], gem)
69.         if o > 0:
70.             print("{0}, {1}".format(s[i], o))
71.             sum += o
72.
73.         i += 1
74.
75.     return sum
76.
77. sum = 0
78. for line in ["Like the instar, tunneling to the surface",
79.     "We must shed our own circumferences;",
80.     "Find the divinity within and emerge."
81. ]:
82.     o = enc(line)
83.     print(o)
84.     if sum == 0:
85.         sum = o
86.     else:
87.         sum *= o
88.
89. print(sum)
RAW Paste Data