Advertisement
Guest User

Untitled

a guest
Nov 8th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. lefts = {}
  2. rights = {}
  3.  
  4. for line in open("ita2.txt", "rb"):
  5. left, right, letter, figure = line.strip().split()
  6.  
  7. if letter == "_":
  8. letter = " "
  9. lefts[left] = (letter, figure)
  10. rights[right] = (letter, figure)
  11.  
  12. # black = 28 56 84 112 140 168 196
  13. # white = 22 44 66 88 110 132
  14. for data in ("22 28 44 28 44 56 88 84 44 28 66 56 44 56 44 56 22 28 22 56 22 140 44 84 44 84 44 84 44 140 22 84 22 56 22 28 22 28 44 28 88 56 22 28 44 28 44 28 88 84 44 " \
  15. + "28 66 28 22 28 66 28 88 28 22 56 132 56 22 28 44 28 22 28 44 28 66 28 110 84 44 28 66 56 22 112 110 28 44 28 110 112 22 28 110 28 22 56 44 28 132 28 110 56 44 56 66 " \
  16. + "28 44 56 44 84 110 84 88 28 22 28 22 28 22 56 22 28 110 28 44 28 22 84 22 140 44 140 66 56 22 84 22 28 132 56 22 112 88 84 132 56 44 56 44 56 22 28 66 28 88 " \
  17. + "28 22 56 22 28 22 28 44 28 22 28 44 28 44 56 44 28 44 112 132 28 66 56 22 84 88 28 22 28 66 28 66 56 132 56 44 56 44 28 132 112 132 28 22 28 22 28 22 56 22 " \
  18. + "28 66 28 110 56 44 28 22 28 44 28 22 28 44 56 22 56 22 28 44 56 44 84 44 28 88 56 22 140 44 140 22 84 88 56 22 28 22 28 110 28 22 56 22 28 44 112 44 28 22 56 " \
  19. + "22 140 44 196 44 28 88 28 44 56 44 56 44 56 22 28 66 28 44 28 44 56 66 84 110 84 22 28 22 28 132 28 22 28 44 84 22 140 44 140 88 84 66 84 44 56 22 140 44",):
  20.  
  21. data = data.split()
  22.  
  23. s = ""
  24. for i in xrange(0, len(data)-2, 2):
  25.  
  26. if int(data[i]) % 22 != 0:
  27. print "bad0"
  28. exit()
  29.  
  30. if int(data[i+1]) % 28 != 0:
  31. print "bad1"
  32. exit()
  33.  
  34. s += "0" * (int(data[i]) / 22)
  35. s += "1" * (int(data[i+1]) / 28)
  36.  
  37. print s
  38. print
  39.  
  40. ss = ""
  41. shift = 0
  42. for i in range(0, len(s)-5, 5):
  43. c = lefts[s[i:i+5]][shift]
  44.  
  45. if c == "[s2f]":
  46. shift = 1
  47. elif c == "[s2l]":
  48. shift = 0
  49. else:
  50. ss += c
  51.  
  52. print ss
  53. print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement