Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. # Traditional way to recurse in every direction
  2. if node in trie.children:
  3. search(board, r+1, c, node, res)
  4. search(board, r-1, c, node, res)
  5. search(board, r, c+1, node, res)
  6. search(board, r, c-1, node, res)
  7.  
  8. # Alternate way
  9. directions = [(0,1), (0,-1), (1,0), (-1,0)]
  10. if node in trie.children:
  11. for i, j in directions:
  12. search(board, r+i, c+j, child, res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement