From 51d675b0d728ca334bc010bf605e97bb6333bead Mon Sep 17 00:00:00 2001 From: VincentSchaik <193274586+VincentSchaik@users.noreply.github.com> Date: Thu, 9 Oct 2025 11:56:51 -0400 Subject: [PATCH 1/4] Assignment-1: Implement Question Two: Valid Bracket Sequence. --- 02_activities/assignments/assignment_1.ipynb | 243 ++++++++++++++++--- 1 file changed, 216 insertions(+), 27 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index f02523c4..14459300 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -25,9 +25,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], "source": [ "import hashlib\n", "\n", @@ -35,8 +43,8 @@ " hash_object = hashlib.sha256(input_string.encode())\n", " hash_int = int(hash_object.hexdigest(), 16)\n", " return (hash_int % 3) + 1\n", - "input_string = \"your_first_name_here\"\n", - "result = hash_to_range(input_string)\n", + "input_string = \"vincent\"\n", + "result = hash_to_range(input_string) # \"vincent\" -> 2\n", "print(result)\n" ] }, @@ -112,13 +120,73 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def is_valid_brackets(s: str) -> bool:\n", - " # TODO\n", - " pass" + " # Check if the length of the input string is even\n", + " # If it's odd, we can immediately return False\n", + " if len(s) % 2 != 0:\n", + " return False\n", + " \n", + " # Use a stack to keep track of opening brackets\n", + " stack = []\n", + " bracket_map = {')': '(', '}': '{', ']': '['}\n", + "\n", + " for char in s:\n", + " # print(\"Current char:\", char)\n", + " # print(\"Current stack:\", stack)\n", + " if char in bracket_map.values(): \n", + " stack.append(char)\n", + " # print(f\"Append: {char} to stack:\", stack)\n", + " elif char in bracket_map.keys():\n", + " if stack == [] or bracket_map[char] != stack.pop():\n", + " # print(f\"Unmatched closing bracket: {char}\")\n", + " return False\n", + " # print(f\"Pop from stack for closing bracket:{bracket_map[char]} {char}\")\n", + " return stack == []" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Input: s = \"([]{})\"\n", + "Output: True\n", + "\n", + "Input: s = \"([)]\"\n", + "Output: False\n", + "\n", + "Input: s = \"()[]{}\"\n", + "Output: True\n", + "\n", + "Input: s = \"[{]}\"\n", + "Output: False\n" + ] + } + ], + "source": [ + "\n", + "print(\"Input: s = \\\"([]{})\\\"\")\n", + "print(\"Output:\", is_valid_brackets(\"([]{})\"))\n", + "\n", + "# print(is_valid_brackets(\"([)]\")) # False\n", + "print(\"\\nInput: s = \\\"([)]\\\"\")\n", + "print(\"Output:\", is_valid_brackets(\"([)]\"))\n", + "\n", + "# print(is_valid_brackets(\"()[]{}\")) # True\n", + "print(\"\\nInput: s = \\\"()[]{}\\\"\")\n", + "print(\"Output:\", is_valid_brackets(\"()[]{}\"))\n", + "\n", + "# print(is_valid_brackets(\"[{]}\")) # False\n", + "print(\"\\nInput: s = \\\"[{]}\\\"\")\n", + "print(\"Output:\", is_valid_brackets(\"[{]}\"))\n" ] }, { @@ -169,7 +237,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# Look at a bracket only string and make sure every opening bracket is closed by the same type in the right sequence." ] }, { @@ -181,11 +249,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Input: s = \"{[()()][]}\"\n", + "Output: True\n", + "\n", + "Input: s = \"((({[}))\"\n", + "Output: False\n" + ] + } + ], "source": [ - "# Your answer here" + "# Input: s = \"{[()()][]}\"\n", + "# Output: True\n", + "print(\"\\nInput: s = \\\"{[()()][]}\\\"\")\n", + "print(\"Output:\", is_valid_brackets(\"{[()()][]}\"))\n", + "\n", + "# Input: s = \"((({[}))\"\n", + "# Output: False\n", + "print(\"\\nInput: s = \\\"((({[}))\\\"\")\n", + "print(\"Output:\", is_valid_brackets(\"((({[}))\"))\n" ] }, { @@ -202,7 +291,38 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "def is_valid_brackets(s: str) -> bool:\n", + " \"\"\"\n", + " Checks if a string of brackets is valid using a Stack ADT.\n", + "\n", + " Args:\n", + " s: The input string containing brackets.\n", + "\n", + " Returns:\n", + " True if the brackets are valid, False otherwise.\n", + " \"\"\"\n", + " # An odd-length string can't have matching pairs.\n", + " if len(s) % 2 != 0:\n", + " return False\n", + "\n", + " # The Stack ADT is implemented using a Python list.\n", + " stack = []\n", + " # A map to hold the matching bracket pairs.\n", + " bracket_map = {')': '(', '}': '{', ']': '['}\n", + "\n", + " for char in s:\n", + " # If it's an opening bracket push it onto the stack.\n", + " if char in bracket_map.values():\n", + " stack.append(char)\n", + " # If it's a closing bracket...\n", + " elif char in bracket_map.keys():\n", + " # The stack can't be empty and the top of the stack\n", + " # must be the matching opening bracket.\n", + " if not stack or bracket_map[char] != stack.pop():\n", + " return False\n", + "\n", + " # If the stack is empty all brackets were matched.\n", + " return not stack\n" ] }, { @@ -214,12 +334,12 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "# Your answer here" + "- The code leverages the Stack ADT. \n", + "- The Last-In, First-Out (LIFO) nature of a stack ensures that the most recently opened bracket is the first one that must be closed. \n", + "- This mirrors the nested structure of valid brackets like ({[]})." ] }, { @@ -231,12 +351,17 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "# Your answer here" + "Time Complexity: O(n)\n", + "- The algorithm iterates through the input string of length n exactly once. \n", + "- Each operation inside the loop—appending to a list (push), popping from a list (pop) and dictionary lookups—takes constant time. \n", + "- The total time complexity is proportional to the length of the string.\n", + "\n", + "Space Complexity: O(n)\n", + "- In the worst-case scenario such as the string \"(((((\", all characters are opening brackets and will be pushed onto the stack. \n", + "- The space required by the stack will be proportional to the length of the input string, n." ] }, { @@ -249,11 +374,75 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# Each pass strips all immediately-adjacent matches\n", + "# If anything is left at the end then some opener and closer brackets are mismatched. \n", + "# The remaining brackets indicate that the string isn’t valid.\n", + "\n", + "# Time Complexity\n", + "# The replace method scans the entire string to find and replace substrings. \n", + "# In the worst case, this operation takes O(n) time for a string of length n.\n", + "# The while loop continues until no more replacements can be made. \n", + "# In the worst case, the loop runs n/2 times where each pass removes one pair of brackets.\n", + "# Therefore, the total time complexity is O(n^2) in the worst case.\n", + "\n", + "# Space Complexity\n", + "# The replace method creates a new string each time it is called which requires O(n) space for the new string.\n", + "# Therefore, the space complexity is O(n).\n", + "\n", + "# Time Complexity: O(n^2)\n", + "# Space Complexity: O(n)\n", + "\n", + "def is_valid_brackets_pairs(s: str) -> bool:\n", + " prev = None\n", + " while prev != s:\n", + " prev = s\n", + " s = (\n", + " s.replace(\"()\", \"\")\n", + " .replace(\"[]\", \"\")\n", + " .replace(\"{}\", \"\")\n", + " )\n", + " return not s" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Input: s = \"([]{})\"\n", + "Output: True\n", + "\n", + "Input: s = \"([)]\"\n", + "Output: False\n", + "\n", + "Input: s = \"()[]{}\"\n", + "Output: True\n", + "\n", + "Input: s = \"[{]}\"\n", + "Output: False\n" + ] + } + ], + "source": [ + "print(\"Input: s = \\\"([]{})\\\"\")\n", + "print(\"Output:\", is_valid_brackets_pairs(\"([]{})\"))\n", + "\n", + "print(\"\\nInput: s = \\\"([)]\\\"\")\n", + "print(\"Output:\", is_valid_brackets_pairs(\"([)]\"))\n", + "\n", + "print(\"\\nInput: s = \\\"()[]{}\\\"\")\n", + "print(\"Output:\", is_valid_brackets_pairs(\"()[]{}\"))\n", + "\n", + "print(\"\\nInput: s = \\\"[{]}\\\"\")\n", + "print(\"Output:\", is_valid_brackets_pairs(\"[{]}\"))\n" ] }, { @@ -290,9 +479,9 @@ " * Open a private window in your browser. Copy and paste the link to your pull request into the address bar. Make sure you can see your pull request properly. This helps the technical facilitator and learning support staff review your submission easily.\n", "\n", "Checklist:\n", - "- [ ] Create a branch called `assignment-1`.\n", - "- [ ] Ensure that the repository is public.\n", - "- [ ] Review [the PR description guidelines](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md#guidelines-for-pull-request-descriptions) and adhere to them.\n", + "- [X] Create a branch called `assignment-1`.\n", + "- [X] Ensure that the repository is public.\n", + "- [X] Review [the PR description guidelines](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md#guidelines-for-pull-request-descriptions) and adhere to them.\n", "- [ ] Verify that the link is accessible in a private browser window.\n", "\n", "If you encounter any difficulties or have questions, please don't hesitate to reach out to our team via our Slack at `#cohort-3-help`. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges." @@ -301,7 +490,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "dsi_participant", "language": "python", "name": "python3" }, @@ -315,7 +504,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.3" } }, "nbformat": 4, From f6c3f93b0861074bf1b4ebd3d767a8ed50f45ff8 Mon Sep 17 00:00:00 2001 From: VincentSchaik <193274586+VincentSchaik@users.noreply.github.com> Date: Wed, 15 Oct 2025 14:43:12 -0400 Subject: [PATCH 2/4] Implement Part 1. Question Two: Path to Leaves. Part 2/3/4 Analyzing partner's Assignment 1. --- 02_activities/assignments/assignment_2.ipynb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/02_activities/assignments/assignment_2.ipynb b/02_activities/assignments/assignment_2.ipynb index 26bb3864..9db7c23d 100644 --- a/02_activities/assignments/assignment_2.ipynb +++ b/02_activities/assignments/assignment_2.ipynb @@ -97,7 +97,23 @@ "# self.left = left\n", "# self.right = right\n", "def is_duplicate(root: TreeNode) -> int:\n", - " # TODO" + " from collections import deque\n", + "\n", + " if root is None:\n", + " return -1\n", + "\n", + " queue = deque([root])\n", + " seen = set()\n", + " while queue:\n", + " node = queue.popleft()\n", + " if node.val in seen:\n", + " return node.val\n", + " seen.add(node.val)\n", + " if node.left is not None:\n", + " queue.append(node.left)\n", + " if node.right is not None:\n", + " queue.append(node.right)\n", + " return -1" ] }, { From 45a521d25d1aade524e437486646908d38ec4b24 Mon Sep 17 00:00:00 2001 From: VincentSchaik <193274586+VincentSchaik@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:35:20 -0400 Subject: [PATCH 3/4] ADS Assignment 2 - Part 1-4 Complete. --- 02_activities/assignments/assignment_2.ipynb | 248 ++++++++++++++++--- 1 file changed, 216 insertions(+), 32 deletions(-) diff --git a/02_activities/assignments/assignment_2.ipynb b/02_activities/assignments/assignment_2.ipynb index 9db7c23d..0c40894b 100644 --- a/02_activities/assignments/assignment_2.ipynb +++ b/02_activities/assignments/assignment_2.ipynb @@ -27,9 +27,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], "source": [ "import hashlib\n", "\n", @@ -37,7 +45,7 @@ " hash_object = hashlib.sha256(input_string.encode())\n", " hash_int = int(hash_object.hexdigest(), 16)\n", " return (hash_int % 3) + 1\n", - "input_string = \"your_first_name_here\"\n", + "input_string = \"vincent\"\n", "result = hash_to_range(input_string)\n", "print(result)\n" ] @@ -156,14 +164,122 @@ "metadata": {}, "outputs": [], "source": [ + "from typing import List\n", + "\n", "# Definition for a binary tree node.\n", - "# class TreeNode(object):\n", - "# def __init__(self, val = 0, left = None, right = None):\n", - "# self.val = val\n", - "# self.left = left\n", - "# self.right = right\n", + "class TreeNode(object):\n", + " def __init__(self, val = 0, left = None, right = None):\n", + " self.val = val\n", + " self.left = left\n", + " self.right = right\n", + "\n", + "# Function to find all root-to-leaf paths in a binary tree\n", "def bt_path(root: TreeNode) -> List[List[int]]:\n", - " # TODO" + " \"\"\"\n", + " This function takes the root of a binary tree as input and returns a list of lists,\n", + " where each inner list represents a path from the root to a leaf node.\n", + " 1. If the tree is empty (root is None), it returns an empty list.\n", + " 2. If the current node is a leaf (both left and right children are None), it returns a list containing a single path with the node's value.\n", + " 3. For non-leaf nodes, it recursively explores the left and right subtrees to find all paths,\n", + " prepending the current node's value to each path found in the subtrees.\n", + " 4. Finally, it returns a list of all root-to-leaf paths.\n", + "\n", + " Args:\n", + " root (TreeNode): The root node of the binary tree.\n", + " \n", + " Returns:\n", + " List[List[int]]: A list of lists, where each inner list is a root-to-leaf path.\n", + "\n", + " Example:\n", + " Given the following binary tree:\n", + " 1\n", + " / \\\n", + " 2 3\n", + " / \\ \\\n", + " 4 5 6 \n", + " \n", + " The function will return:\n", + " [[1, 2, 4], [1, 2, 5], [1, 3, 6]]\n", + " \"\"\"\n", + " \n", + " # Base case - Tree is empty\n", + " if root is None:\n", + " return []\n", + " \n", + " # Base case = Leaf node where both left and right children are None\n", + " if root.left is None and root.right is None:\n", + " return [[root.val]]\n", + " \n", + " # Recursive case - Explore left and right subtrees\n", + " paths = []\n", + "\n", + " # Explore left subtree\n", + " for p in bt_path(root.left):\n", + " # Prepend current node's value to each path from left subtree\n", + " paths.append([root.val] + p)\n", + " \n", + " # Explore right subtree\n", + " for p in bt_path(root.right):\n", + " # Prepend current node's value to each path from right subtree\n", + " paths.append([root.val] + p)\n", + "\n", + " # Return all root-to-leaf paths\n", + " return paths" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[1, 2, 3], [1, 2, 5], [1, 2, 6], [1, 2, 7]]\n" + ] + } + ], + "source": [ + "# Example 1:\n", + "# Input: root = [1, 2, 2, 3, 5, 6, 7]\n", + "# Output: [[1, 2, 3], [1, 2, 5], [1, 2, 6], [1, 2, 7]]\n", + "\n", + "root = TreeNode(1)\n", + "root.left = TreeNode(2)\n", + "root.right = TreeNode(2)\n", + "root.left.left = TreeNode(3)\n", + "root.left.right = TreeNode(5)\n", + "root.right.left = TreeNode(6)\n", + "root.right.right = TreeNode(7)\n", + "\n", + "print(bt_path(root)) # Expected output: [[1, 2, 3], [1, 2, 5], [1, 2, 6], [1, 2, 7]]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[10, 9, 8], [10, 7]]\n" + ] + } + ], + "source": [ + "# Example 2:\n", + "# Input: root = [10, 9, 7, 8]\n", + "# Output: [[10, 7], [10, 9, 8]]\n", + "\n", + "root = TreeNode(10)\n", + "root.left = TreeNode(9)\n", + "root.right = TreeNode(7)\n", + "root.left.left = TreeNode(8)\n", + "\n", + "print(bt_path(root)) # Expected output: [[10, 9, 8], [10, 7]]\n" ] }, { @@ -243,7 +359,11 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# Reference: Jesscode-analyst. \n", + "# Assignment 1 – Algorithms and Data Structures. \n", + "# GitHub. https://github.com/Jesscode-analyst/algorithms_and_data_structures/blob/93f87391c1a4685dd35a4d5b940e94e1608ef6df/02_activities/assignments/assignment_1.ipynb\n", + "\n", + "# Problem: Find the first repeated number in a list. Return -1 if there are no duplicates." ] }, { @@ -260,7 +380,28 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# Example 1: Expecting duplicate 2. Returns 2\n", + "# Input = [2, 4, 5, 6, 2, 5, 7]\n", + "# Output: 2\n", + "\n", + "# Example 2: Expecting no duplicate. Returns -1\n", + "# Input = [5, 6, 7, 8]\n", + "# Output: -1\n", + "\n", + "\n", + "# Partner's Example 1:\n", + "# Input list with multiple duplicates, but the first duplicate is 7\n", + "# nums = [5, 7, 3, 7, 3, 2, 1]\n", + "# Output should be the first number that repeats: 7\n", + "# print(first_duplicate(nums)) # Expected output: 7\n", + "\n", + "# Trace/Walkthrough:\n", + "# Start with an empty set seen = {}\n", + "# 5 → not in seen, add 5 → seen = {5}\n", + "# 7 → not in seen, add 7 → seen = {5, 7}\n", + "# 3 → not in seen, add 3 → seen = {3, 5, 7}\n", + "# 7 → already in seen → duplicate found, return 7\n", + "# Result: 7\n" ] }, { @@ -273,11 +414,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n", + "-1\n" + ] + } + ], "source": [ - "# Your answer here" + "# Reference: Jesscode-analyst. \n", + "# Assignment 1 – Algorithms and Data Structures. \n", + "# GitHub: https://github.com/Jesscode-analyst/algorithms_and_data_structures/blob/assignment-1/02_activities/assignments/assignment_1.ipynb\n", + "\n", + "from typing import List\n", + "\n", + "def first_duplicate(nums: List[int]) -> int:\n", + " \n", + " seen = set() # Abstract data type: set for O(1) lookups\n", + " \n", + " for num in nums:\n", + " if num in seen:\n", + " return num \n", + " seen.add(num) # Add number to set\n", + " return -1 # No duplicates found\n", + "\n", + "# New example test cases\n", + "\n", + "# Example 1: first duplicate is 7\n", + "nums1 = [5, 7, 3, 7, 3, 2, 1]\n", + "print(first_duplicate(nums1)) # Expected output: 7\n", + "\n", + "# Example 2: no duplicates\n", + "nums2 = [10, 27, 30, 42, 50]\n", + "print(first_duplicate(nums2)) # Expected output: -1" ] }, { @@ -290,11 +464,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# Explanation:\n", + "# The function goes through each number in the list and keeps track of what it has already seen using a set. \n", + "# If it encounters a number that’s already in the set that means it’s a duplicate and is returned. \n", + "# If it finishes going through the list without finding any duplicates then it returns -1.\n" ] }, { @@ -311,7 +488,8 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# Time complexity: O(n) — The function looks at each number only once.\n", + "# Space complexity: O(n) — In the worst case where there is no duplicates, it stores every number in the set." ] }, { @@ -328,7 +506,9 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# The code works great. It’s simple and easy to read. \n", + "# One small suggestion would be to add a short description at the top explaining what the function does.\n", + "# Example: Function to find the first repeated number in a list. Returns -1 if there are no duplicates." ] }, { @@ -354,7 +534,18 @@ "metadata": {}, "outputs": [], "source": [ - "# Your answer here" + "# For this assignment I was paired with another student to review their notebook solution to Assignment-1. \n", + "# The solution was finding the first repeated number in a list. \n", + "# My task was to read the code and use examples to see how it worked.\n", + "# The logic was clear. It used a set to keep track of numbers already seen. \n", + "# As it went through the list, it returned the first number that showed up again. \n", + "# If there were no repeats, it returned -1. \n", + "# \n", + "# I traced one example step by step and made my own to test my understanding.\n", + "# This process helped me get better at reading code and thinking through its steps without running it. \n", + "\n", + "# The review helped me focus on how to read code carefully and spot what makes it work well. \n", + "# It provided me the opportunity to analyze and critique a solutions emulating a real life code review." ] }, { @@ -394,25 +585,18 @@ " * Open a private window in your browser. Copy and paste the link to your pull request into the address bar. Make sure you can see your pull request properly. This helps the technical facilitator and learning support staff review your submission easily.\n", "\n", "Checklist:\n", - "- [ ] Created a branch with the correct naming convention.\n", - "- [ ] Ensured that the repository is public.\n", - "- [ ] Reviewed the PR description guidelines and adhered to them.\n", - "- [ ] Verify that the link is accessible in a private browser window.\n", + "- [X] Created a branch with the correct naming convention.\n", + "- [X] Ensured that the repository is public.\n", + "- [X] Reviewed the PR description guidelines and adhered to them.\n", + "- [X] Verify that the link is accessible in a private browser window.\n", "\n", "If you encounter any difficulties or have questions, please don't hesitate to reach out to our team via our Slack at `#cohort-6-help`. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges.\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "dsi_participant", "language": "python", "name": "python3" }, @@ -426,7 +610,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.3" } }, "nbformat": 4, From 91ff2aee12c44672c8b523188f0290f836cf6e06 Mon Sep 17 00:00:00 2001 From: VincentSchaik <193274586+VincentSchaik@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:42:16 -0400 Subject: [PATCH 4/4] ADS Assignment 2 Part 1-4 Complete. --- 02_activities/assignments/assignment_2.ipynb | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/02_activities/assignments/assignment_2.ipynb b/02_activities/assignments/assignment_2.ipynb index 0c40894b..5c0f9724 100644 --- a/02_activities/assignments/assignment_2.ipynb +++ b/02_activities/assignments/assignment_2.ipynb @@ -160,9 +160,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "<>:12: SyntaxWarning: invalid escape sequence '\\ '\n", + "<>:12: SyntaxWarning: invalid escape sequence '\\ '\n", + "/var/folders/5h/h1f0cx75553g3c45m_p5b0k80000gn/T/ipykernel_70571/2821756286.py:12: SyntaxWarning: invalid escape sequence '\\ '\n", + " \"\"\"\n" + ] + } + ], "source": [ "from typing import List\n", "\n", @@ -229,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -258,7 +269,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -414,7 +425,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -464,7 +475,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -540,12 +551,10 @@ "# The logic was clear. It used a set to keep track of numbers already seen. \n", "# As it went through the list, it returned the first number that showed up again. \n", "# If there were no repeats, it returned -1. \n", - "# \n", "# I traced one example step by step and made my own to test my understanding.\n", "# This process helped me get better at reading code and thinking through its steps without running it. \n", - "\n", "# The review helped me focus on how to read code carefully and spot what makes it work well. \n", - "# It provided me the opportunity to analyze and critique a solutions emulating a real life code review." + "# It provided me the opportunity to analyze and critique a solutions emulating a real life code review. " ] }, {