
Week 3, Wednesday
January 22, 2026
96 moments of zen π΅ 95 grateful neurons π΅ 94 clever insights π΅ 93 aha moments π΅ 92 merge conflicts π΅ 91 Stack Overflow tabs π΅ 90 refactored functions π΅ 89 git commits π΅ 88 test cases π΅ 87 rubber ducks π΅ 86 coffee refills π΅ 85 keyboard clicks π΅ 84 documentation pages π΅ 83 variable names π΅ 82 edge cases π΅ 81 print statements π΅ 80 whiteboard markers π΅ 79 Piazza posts π΅ 78 recursive calls π΅ 77 helper functions π΅ 76 code reviews π΅ 75 unit tests π΅ 74 bug fixes π΅ 73 loop iterations π΅ 72 hash collisions π΅ 71 array indices π΅ 70 base cases π΅ 69 pointer errors π΅ 68 syntax errors π΅ 67 runtime exceptions π΅ 66 stack frames π΅ 65 heap allocations π΅ 64 binary digits π΅ 63 terminal commands π΅ 62 Slack messages π΅ 61 Discord pings π΅ 60 Zoom breakouts π΅ 59 office hours π΅ 58 study sessions π΅ 57 flashcards π΅ 56 practice problems π΅ 55 lecture notes π΅ 54 code snippets π΅ 53 TODO comments π΅ 52 FIXME tags π΅ 51 deprecation warnings π΅ 50 linter errors π΅ 49 type hints π΅ 48 docstrings π΅ 47 assert statements π΅ 46 boundary checks π΅ 45 null pointers π΅ 44 empty lists π΅ 43 off-by-ones π΅ 42 infinite loops π΅ 41 segfaults π΅ 40 memory leaks π΅ 39 cache misses π΅ 38 race conditions π΅ 37 deadlocks π΅ 36 timeouts π΅ 35 snack breaks π΅ 34 memes shared π΅ 33 playlists made π΅ 32 naps attempted π΅ 31 alarms snoozed π΅ 30 tabs still open π΅ 29 unread emails π΅ 28 doodles drawn π΅ 27 songs on repeat π΅ 26 empty notebooks π΅ 25 highlighters π΅ 24 sticky notes π΅ 23 βalmost donesβ π΅ 22 existential crises π΅ 21 snacks consumed π΅ 20 walks taken π΅ 19 deep breaths π΅ 18 pokemons π΅ 17 demos π΅ 16 pull requests π΅ 15 code comments π΅ 14 merge commits π΅ 13 Piazza posts π΅ 12 cups of ramen π΅ 11 syntax errors π΅ 10 ChatGPT tabs π΅ 9 hours of sleep π΅ 8 TA office hours π΅ 7 Pomodoros π΅ 6 study rooms π΅ 5 passing tests π΅ 4 stretch breaks π΅ 3 docs read π΅ 2 good friends π΅ And a latte from Loafe.
How many treats will you receive on the 96th day (Apr 10)?
\[1 + 2 + 3 + \ldots + 96 = \sum_{k=1}^{96} k = \text{ ?}\]
Claim: \(f(n) = \frac{n(n+1)}{2}\) where \(f(n) = \sum_{k=1}^{n} k\)
Proof: Consider an arbitrary \(n >= 0\). Then we have the following cases:
Case 1, \(n = 0\) (base case): \(f(0) = 0 = \frac{0 \cdot 1}{2}\) β
Case 2, \(n>0\) (inductive case):
Assume for any \(0 < j < n\), \(f(j) = \frac{j(j+1)}{2}\) (Inductive Hypothesis)
\(f(n) = f(n-1) + n\) by definition.
\(f(n-1) = \frac{(n-1)(n)}{2}\) by IH, since \(n-1 < n\).
\(f(n) = \frac{(n-1)(n)}{2} + n = \frac{(n)(n+1)}{2}\) by algebra. β

A recursive mathematical function:
\[f(n) = \begin{cases} 0 & \text{if } n = 0 \\ f(n-1) + n & \text{if } n > 0 \end{cases}\]
| Induction | Math | Recursion |
|---|---|---|
| Consider arbitrary \(n \geq 0\) | \(n\in \mathbb{N}\) | def f(n): |
| Case \(n = 0\): prove directly | \(0\) if \(n=0\) | if n == 0: return 0 |
| Case \(n > 0\): assume \(P(j)\) for \(j < n\) | \(f(n-1)\) defined | Trust f(n-1) works |
| Prove \(P(n)\) using IH | \(f(n-1)+n\) if \(n>0\) | Compute f(n) using f(n-1) |
Same structure. Same reasoning.
Consider the math:
\[f(n) = \begin{cases} 0 & \text{if } n = 0 \\ f(n-1) + n & \text{if } n > 0 \end{cases}\]
When you write triangle(n - 1), trust that it works.
This is exactly like relying on the inductive hypothesis in a proof.
Donβt trace through every call. Just ask:
triangle(n-1) magically gives me the right answer, does my code use it correctly?For the recursion to work its magic, your code must satisfy:
Handle all valid inputs: Every input needs a case (base or recursive)
Have a base case: At least one case that returns without recursing
Make progress: Each recursive call must get closer to a base case
What if we split the triangle differently?

\[f(n) = 2 \cdot f(\lfloor n/2 \rfloor) + (n - \lfloor n/2 \rfloor)^2\]
Works for all \(n\).
I forgot to define triangle_fast!
Both compute the same answer.
But the recursive structures are different:
triangle(n): calls triangle(n-1)triangle_fast(n): calls triangle_fast(n//2)Does that matter?
Letβs race them!
triangle(n): \(f(n) = f(n-1) + n\)
triangle_fast(n): \(f(n) = 2 \cdot f(n/2) + (n/2)^2\)
The same problem can have multiple recursive structures.
Different structures lead to different code and different performance.
This is the heart of algorithm design.
The triangle race was a preview: smart decomposition β fast algorithms.