Neuron 101

Solving by search / DFS

Türkçe

Plate15

Unit 2 · Topic 4 of 10

DFS

Easy, 6 min, 9 steps

S
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 9 Maze

The maze

S is the start and the flag is the goal. Black blocks are walls, brown cells are mud: entering mud costs 3, entering a plain cell costs 1. DFS ignores the mud too.

Tap a part of the scene to see its details here.

Open in Colab
  1. def dfs(harita, S, G):
  2. yigin = [S]
  3. kapali = set()
  4. ebeveyn = {}
  5. while yigin:
  6. x = yigin.pop()
  7. if x in kapali:
  8. continue
  9. kapali.add(x)
  10. if x == G:
  11. break
  12. for k in komsular(harita, x):
  13. if k not in kapali:
  14. ebeveyn[k] = x
  15. yigin.append(k)
  16. return ebeveyn
acilan
0
sinir
1
yolUzunlugu
0
maliyet
0