From a7ee5d06a024f44f6a34142630fa2219853bbf98 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Tue, 21 Jul 2026 21:06:54 -0400 Subject: [PATCH] Add in-progress notes for 2026.07.21 --- notes-and-examples/2026.07.21/main.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 notes-and-examples/2026.07.21/main.py diff --git a/notes-and-examples/2026.07.21/main.py b/notes-and-examples/2026.07.21/main.py new file mode 100644 index 0000000..6c7a782 --- /dev/null +++ b/notes-and-examples/2026.07.21/main.py @@ -0,0 +1,25 @@ +# Adjacency list +first_graph = { + 1: [3, 20], + 2: [20], + 3: [1, 20], + 20: [2, 3] +} + +# First exercise: go from 1, to 20, to 2 +first_graph[first_graph[1][1]][0] + +# pass visited by reference +def depth_first_search(graph: dict, start, visited=set()): + print(start) + if len(visited)==len(graph): + return visited + + for x in graph[start]: + if x not in visited: + visited.add(x) + return depth_first_search(graph, x, visited) + pass + + +depth_first_search(first_graph, 1)