Small games and the code behind them. Short coding lessons with real code and real output.

New Delhi
Joined January 2021
Python dynamic programming with lru_cache, in 4 images. 🐍 One decorator, one table, one rule: solve each subproblem once. #Python #Coding
1
1
24
Python heapq with tuples, in 4 images. 🐍 #Python #Coding
1
1
9
Full video, Dijkstra and Weighted Graphs: youtu.be/q77VxBaM-zc
2
Python Dijkstra's algorithm with heapq, in 4 images. 🐍 A weighted graph, a heap, and one rule: keep the cheaper distance. #Python #Coding
1
1
17
Python heapq with tuples. 🐍 heappush(heap, (3, "A")) heappop(heap) -> 1 C, 3 A, 3 B, 4 D Distance first = cheapest first. #Python #Coding
1
6
Full video, Dijkstra and Weighted Graphs: youtu.be/q77VxBaM-zc
Python Dijkstra's algorithm with heapq. 🐍 → fewest steps ≠ cheapest path → always finish the closest node → relax: keep the cheaper distance → negative weight = wrong answer #Python #Coding
1
1
8
Watch it here: youtu.be/q77VxBaM-zc Next up: dynamic programming.
1
Shortest path with a queue, in 4 images. 🐍 #Python #Coding
1
1
13
Shortest path in Python in 13 lines. 🐍 queue = deque([["A"]]) path = queue.popleft() queue.append(path + [n]) -> ['A', 'C', 'F'] #Python #Coding
1
1
5
How to find the shortest path in a graph, in 4 images. 🐍 A dict of neighbours, a queue, a seen set. #Python #Coding
1
1
8
A Python script can carry its own dependencies, in 4 images. 🐍 #Python #Coding
1
1
11
Full video, Packaging with uv: youtu.be/iwxg14e4ro4
1
A Python script can list its own dependencies in a comment. 🐍 # /// script # dependencies = ["requests"] # /// -> uv run installs it #Python #Coding
1
1
11
Full video, Packaging with uv: youtu.be/iwxg14e4ro4
2