This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "role": "system", | |
| "content": "You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n- read: Read file contents\n- bash: Execute bash commands (ls, grep, find, etc.)\n- edit: Make precise file edits with exact text replacement, including multiple disjoint edits in one call\n- write: Create or overwrite files\n- checklist: Track progress through task requirements (init/done/status)\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n- Use bash for file operations like ls, rg, find\n- Use read to examine files instead of cat or sed.\n- You can inspect PI_* environment variables for current model and session details.\n- Use edit for precise changes (edits[].oldText must match exactly)\n- When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "role": "system", | |
| "content": "You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n- read: Read file contents\n- bash: Execute bash commands (ls, grep, find, etc.)\n- edit: Make precise file edits with exact text replacement, including multiple disjoint edits in one call\n- write: Create or overwrite files\n- checklist: Track progress through task requirements (init/done/status)\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n- Use bash for file operations like ls, rg, find\n- Use read to examine files instead of cat or sed.\n- Inspect PI_* environment variables for current model and session details.\n- Use edit for precise changes (edits[].oldText must match exactly)\n- When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of mult |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding=utf-8 | |
| """Sudoku solver using constraint propogation + search""" | |
| from collections import defaultdict | |
| from itertools import chain, product | |
| from pprint import pprint | |
| from typing import List | |
| CELLS = None | |
| UNITS = None | |
| PEERS = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution: | |
| def setZeroes(self, matrix): | |
| """ | |
| :type matrix: List[List[int]] | |
| :rtype: void Do not return anything, modify matrix in-place instead. | |
| """ | |
| row_0 = col_0 = False | |
| # step 1: iterate through matrix and set 0 markers in 1st row and col (except top left) | |
| for row_idx, row in enumerate(matrix): | |
| for col_idx, val in enumerate(row): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def detect_cycles(graph: dict) -> bool: | |
| """Return whether or not graph has any cycles.""" | |
| visited = set() | |
| path = set() | |
| def visit(node): | |
| """Return True if node is in a cycle""" | |
| if node in visited: | |
| return False | |
| visited.add(node) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, val, left=None, right=None): | |
| self.val = val | |
| self.left = left | |
| self.right = right | |
| def is_bst_rec(node: Node, min_v: object = None, max_v: object = None) -> bool: # todo should use float('inf') and float('-inf') | |
| if (min_v and node.val < min_v) or (max_v and node.val > max_v): | |
| return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| EXAMPLES | |
| Puzzle 1: | |
| [0, 1, 4] | |
| [2, 3, 5] | |
| [8, 7, 6] | |
| Longest chain is [4, 5, 6, 7, 8] with length 5. | |
| Puzzle 2: | |
| [0, 2] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| if __name__ == "__main__": | |
| # define and initialize queue variables | |
| lambd_in = 0.5 | |
| lambd_out = 0.4 | |
| closing_time = 100 | |
| t = 0 | |
| num_arrivals = 0 | |
| num_departures = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import numpy as np | |
| # for graphing | |
| from mpl_toolkits.mplot3d.axes3d import Axes3D | |
| import matplotlib.pyplot as plt | |
| if __name__ == "__main__": | |
| # setting up scatterplot | |
| Xa = [] | |
| Ya = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 8 Tile Solver | |
| # Written by Daniel Ong for COEN 166: Artificial Intelligence | |
| # | |
| # A comparison of the real time taken to solve an n tile puzzle using: | |
| # 1. Iterative deepening depth-first search | |
| # 2. Depth-first search | |
| # 3. Breadth-first search | |
| # Tested on the 8 tile puzzle | |
| # Some code adapted from Edd Mann's blog post: http://eddmann.com/posts/using-iterative-deepening-depth-first-search-in-python/ |
NewerOlder