Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1.  
  2.  
  3. movemap1 = {
  4.   '1': {'D':'4', 'R':'2'},
  5.   '2': {'D':'5', 'R':'3', 'L':'1'},
  6.   '3': {'L':'2', 'D':'6'},
  7.   '4': {'U':'1', 'D':'7', 'R':'5'},
  8.   '5': {'U':'2', 'D':'8', 'L':'4', 'R':'6'},
  9.   '6': {'U':'3', 'D':'9', 'L':'5'},
  10.   '7': {'U':'4', 'R':'8'},
  11.   '8': {'U':'5', 'L':'7', 'R':'9'},
  12.   '9': {'U':'6', 'L':'8'}
  13. }
  14.  
  15. movemap2 = {
  16.     '1': {'D':'3'},
  17.     '2': {'R':'3', 'D':'6'},
  18.     '3': {'U':'1', 'D':'7', 'L':'2', 'R':'4'},
  19.     '4': {'D':'8', 'L':'3'},
  20.     '5': {'R':'6'},
  21.     '6': {'U':'2', 'D':'A', 'L':'5', 'R':'7'},
  22.     '7': {'U':'3', 'D':'B', 'L':'6', 'R':'8'},
  23.     '8': {'U':'4', 'D':'C', 'L':'7', 'R':'9'},
  24.     '9': {'L':'8'},
  25.     'A': {'U':'6', 'R':'B'},
  26.     'B': {'U':'7', 'D':'D', 'L':'A', 'R':'C'},
  27.     'C': {'U':'8', 'L':'B'},
  28.     'D': {'U':'B'}
  29.  
  30. }
  31.  
  32. movemap = movemap2
  33.  
  34. location = '5'
  35. code = []
  36.  
  37.  
  38. f = open('realcode','rb')
  39.  
  40. for line in f.readlines():
  41.     for x in range(len(line)):
  42.         if line[x] in movemap[location].keys():
  43.             location = movemap[location][line[x]]
  44.     code.append(location)
  45.  
  46.  
  47. print code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement