My code currently runs 4865ms for DFS and 4458 for BFS, im trying to optimize this a bit. I am not the greatest python coder but know some basic stuff. Any hints or suggestions would be great!
def bfs(rot):
n = deque()
n.append((rot, 0))
while n:
inga, lvl = n.popleft()
if inga.ratatosk:
return lvl
if inga.barn:
for i in inga.barn:
n.append((i,lvl+1))
(Side note, input is given as a text file and which search is run is later in my code, just say if any of that is needed)
Thanks Dream!

New Topic/Question
Reply



MultiQuote


|