From 82ff1c82b06feee34a2d3696b6a847d428824528 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 9 Apr 2026 09:51:40 -0700 Subject: [PATCH] Add 2026.04.08 function stack example and homework --- .../2026.04.08/function_stack.py | 12 ++++++++++++ shared/notes-and-examples/2026.04.08/homework.py | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 shared/notes-and-examples/2026.04.08/function_stack.py create mode 100644 shared/notes-and-examples/2026.04.08/homework.py diff --git a/shared/notes-and-examples/2026.04.08/function_stack.py b/shared/notes-and-examples/2026.04.08/function_stack.py new file mode 100644 index 0000000..0721d89 --- /dev/null +++ b/shared/notes-and-examples/2026.04.08/function_stack.py @@ -0,0 +1,12 @@ +# Simple function stack example: Fibonacci sequence +# fibonacci(0) -> 0 +# fibonacci(1) -> 1 +# fibonacci(2) -> 1 (0 + 1) +# fibonacci(3) -> 2 (1 + 1) +# fibonacci(4) -> 3 (1 + 2) +# fibonacci(5) -> 5 (2 + 3) +# fibonacci(6) -> 8 (3 + 5) + + +def fibonacci(n: int): + pass diff --git a/shared/notes-and-examples/2026.04.08/homework.py b/shared/notes-and-examples/2026.04.08/homework.py new file mode 100644 index 0000000..55a10c5 --- /dev/null +++ b/shared/notes-and-examples/2026.04.08/homework.py @@ -0,0 +1,14 @@ +# Make a calculator using Reverse Polish Notation. Use recursion. +# The Reverse Polish syntax completely removes the need for parentheses. +# +# Syntax examples: +# "3 + 2" -> ["3", "2", "+"] +# "3 * 4 + 2" -> ["3", "4", "*", "2", "+"] +# "3 * (4 + 2)" -> ["3", "4", "2", "+", "*"] +# +# Example for how to evaluate ["3", "4", "2", "+", "*"]: +# Start with "4 2 +" -> "6" +# Then "3 6 *" -> "18" +# Start with the "innermost" expression and work backwards (this is the recursion part) +# +# For help, email me@bchen.dev