Guest User

Untitled

a guest
Dec 10th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1.     def read_file(name):
  2.         f = open(name,'r')
  3.         result = []    
  4.         for line in f:
  5.             result.append(IO.feed_line(line))
  6.         return result
  7.        
  8.     def feed_line(line):
  9.         result = []    
  10.         for x in line:
  11.             if x!=' ' and x!='\n':
  12.                 if ord(x)>=ord('0') and ord(x)<=ord('9'): # integer
  13.                     result.append(int(x))
  14.                 else:   #ascci to integer>=10
  15.                     IO.hashmap[ord(x)-55]=x
  16.                     result.append(ord(x)-55)
  17.         return result
  18.  
  19.     def print_solution(node_list):
  20.         if node_list is not None:
  21.             path=node_list.path()
  22.             path.reverse()
  23.             for n in path:
  24.                 for line in n.state.array:
  25.                     l = ""
  26.                     for val in line:
  27.                         if val>9:
  28.                             l += IO.hashmap[val]
  29.                         else:
  30.                             l += str(val)
  31.                         l += " "
  32.                     print(l)
  33.                 print("")
  34.         else:
  35.             print("No solution")
Add Comment
Please, Sign In to add comment