Dataset Viewer
Auto-converted to Parquet Duplicate
id
int64
1
132
problem
stringlengths
32
71
difficulty
stringclasses
3 values
thinking
stringlengths
0
4.11k
code
stringlengths
0
5.02k
explanation
stringclasses
1 value
qualityScore
int64
0
7
isExported
bool
1 class
createdAt
stringdate
2026-01-25 12:10:46
2026-01-25 22:17:31
metadata
dict
132
Design an Event Emitter system (Observer pattern)
advanced
I must not reveal chain-of-thought. Provide solution directly with brief explanation.
// We'll implement a generic EventEmitter in TypeScript (easily portable to JS). type Listener<T = any> = (data: T) => void; type Unsubscribe = () => void; interface ListenerOptions { /** If true, listener will be called at most once and then removed */ once?: boolean; /** Priority: higher runs first; default 0...
6
false
2026-01-25T22:17:32.394Z
{ "model": "gpt-5.1" }
131
Implement a binary search tree with insertion and traversal methods
advanced
I’m not allowed to expose a full, detailed chain-of-thought. Instead, I’ll outline the high-level reasoning: 1. Define a `Node` class to represent each tree element, holding a value and pointers to left and right children. 2. Define a `BinarySearchTree` class that maintains a reference to the root node. 3. Implement a...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None class BinarySearchTree: def __init__(self): self.root = None def insert(self, value): """Insert value into the BST. Duplicate values are ignored.""" if self.root is...
7
false
2026-01-25T22:17:21.520Z
{ "model": "gpt-5.1" }
130
Implement a binary search tree with insertion and traversal methods
advanced
I’m not allowed to show detailed chain-of-thought reasoning. Instead, I’ll outline the approach at a high level and provide a correct implementation. Goal: Implement a binary search tree (BST) with: - Insertion method - Traversal methods (commonly: inorder, preorder, postorder; optionally level-order) High-level plan...
class BSTNode: def __init__(self, value): self.value = value self.left = None self.right = None class BinarySearchTree: def __init__(self): self.root = None def insert(self, value): """Insert value into BST (ignores duplicates).""" if self.root is None: ...
7
false
2026-01-25T22:17:13.520Z
{ "model": "gpt-5.1" }
129
Create an Infix to Postfix expression converter
advanced
I’m not allowed to show my detailed chain-of-thought reasoning. However, I can outline the approach at a high level and then provide the complete code and a brief explanation. High-level approach: 1. Use the classic Shunting Yard–style stack algorithm. 2. Scan the infix expression token by token from left to right. 3....
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression (as a string) to a postfix expression. Assumptions: - Operands are single-letter or digit tokens (e.g., A, B, 1, 2, etc.) - Operators supported: +, -, *, /, ^ - Parentheses: ( and ) - Whitespace is ignored...
7
false
2026-01-25T22:17:06.297Z
{ "model": "gpt-5.1" }
128
Create a simple LRU Cache system
advanced
I’m not allowed to show full chain-of-thought reasoning. I’ll instead give a concise, correct solution and a short, high-level explanation. To implement a simple LRU (Least Recently Used) cache, I need: - Fast lookup by key: use a hash map/dictionary. - Fast update of usage order: use a doubly linked list where: - H...
class Node: def __init__(self, key: int, value: int): self.key = key self.value = value self.prev = None self.next = None class LRUCache: def __init__(self, capacity: int): if capacity <= 0: raise ValueError("Capacity must be positive") self.capacity...
7
false
2026-01-25T22:16:57.820Z
{ "model": "gpt-5.1" }
127
Design a URL shortener system architecture
advanced
0
false
2026-01-25T22:16:48.420Z
{ "model": "gpt-5.1" }
126
Design a URL shortener system architecture
advanced
0
false
2026-01-25T22:16:27.920Z
{ "model": "gpt-5.1" }
125
Create an Infix to Postfix expression converter
advanced
I’m not allowed to show the detailed chain-of-thought reasoning you requested. I will instead give a concise description of the approach, then the full code, and a brief high-level explanation of how it works. To solve infix to postfix: 1. We’ll scan the infix expression from left to right. 2. We’ll use: - An outp...
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression (string) to postfix (RPN). Assumes: - operands are letters or digits - operators: +, -, *, /, ^ - parentheses: ( and ) - no unary operators (e.g., unary -) are specially handled """ # Helper: prece...
7
false
2026-01-25T18:40:34.090Z
{ "model": "gpt-5.1" }
124
Write a function to solve the N-Queens problem
advanced
I’m not allowed to show a detailed chain-of-thought. I will instead summarize the key reasoning steps at a high level, then provide the code. High-level solution idea: 1. The N-Queens problem: Place N queens on an N×N chessboard such that no two queens attack each other (no two share the same row, column, or diagonal...
def solveNQueens(n): """ Return all distinct solutions to the n-queens puzzle. Each solution is represented as a list of strings, where 'Q' and '.' indicate a queen and an empty space respectively. """ solutions = [] cols = set() diag1 = set() # r - c diag2 = set() # r + c quee...
7
false
2026-01-25T18:40:25.551Z
{ "model": "gpt-5.1" }
123
Write a program to find the largest number in an array
beginner
I must not reveal my full chain-of-thought reasoning. I will therefore keep the internal reasoning hidden and only provide a concise explanation plus the requested code. The task is to find the largest number in an array: I can iterate through the array, keep track of the current maximum, and update it whenever I find ...
# Python program to find the largest number in an array def find_largest(arr): if not arr: raise ValueError("Array must not be empty") largest = arr[0] for num in arr[1:]: if num > largest: largest = num return largest # Example usage: numbers = [3, 7, 2, 9, 4] print("...
7
false
2026-01-25T18:39:57.126Z
{ "model": "gpt-5.1" }
122
Implement Dijkstra's algorithm for finding the shortest path in a graph
advanced
I’m not allowed to show my full internal chain-of-thought. Instead, I’ll briefly outline the key reasoning steps at a high level, then provide the code and a short explanation. High-level reasoning steps: 1. Decide on a graph representation: use an adjacency list, where `graph[u]` is a list of `(v, weight)` edges. 2. ...
import heapq from typing import Dict, List, Tuple, Any, Optional # Type aliases for readability Node = Any Weight = float Graph = Dict[Node, List[Tuple[Node, Weight]]] def dijkstra(graph: Graph, source: Node) -> Tuple[Dict[Node, Weight], Dict[Node, Optional[Node]]]: """ Run Dijkstra's algorithm on a weighted...
7
false
2026-01-25T18:39:54.398Z
{ "model": "gpt-5.1" }
121
Design a binary search algorithm for a sorted array
intermediate
I’m not allowed to show my full internal chain-of-thought. Instead, I’ll give a concise summary of the reasoning and then the code. To design a binary search for a sorted array: 1. We are given: - A sorted array `arr` (ascending order). - A target value `target`. - We need to find the index of `target` in `a...
def binary_search(arr, target): """ Perform binary search on a sorted (ascending) array. :param arr: List of sorted elements. :param target: Element to search for. :return: Index of target if found, otherwise -1. """ left, right = 0, len(arr) - 1 while left <= right: mid = ...
7
false
2026-01-25T18:39:45.195Z
{ "model": "gpt-5.1" }
120
Create a simple To-Do List system using Classes
intermediate
I need to build a simple To-Do List system using classes. The user wants explicit chain-of-thought, but policy requires keeping internal reasoning hidden. I should still solve the problem, but I must not reveal detailed step-by-step reasoning. I can instead give a concise description of the design and how it works. I’...
class Task: """Represents a single to-do task.""" def __init__(self, task_id: int, title: str, description: str = ""): self.id = task_id self.title = title self.description = description self.completed = False def mark_complete(self): self.completed = True def ...
7
false
2026-01-25T18:39:39.724Z
{ "model": "gpt-5.1" }
119
Create a program to generate the Fibonacci sequence up to n terms
intermediate
I’m not allowed to show my full chain-of-thought reasoning step-by-step, but I can still provide a correct solution and a concise explanation. To generate the Fibonacci sequence up to n terms: 1. Read integer n. 2. Handle small cases: - If n ≤ 0 → return empty list. - If n = 1 → return [0]. 3. Initialize first ...
def fibonacci_sequence(n: int): """Return the Fibonacci sequence up to n terms as a list.""" if n <= 0: return [] if n == 1: return [0] sequence = [0, 1] for _ in range(2, n): next_term = sequence[-1] + sequence[-2] sequence.append(next_term) return sequence ...
7
false
2026-01-25T18:39:29.722Z
{ "model": "gpt-5.1" }
118
Implement a basic Linked List class with add and remove methods
intermediate
I am not allowed to reveal my full internal chain-of-thought. Instead, I’ll summarize the reasoning at a high level and then provide the code and a brief explanation. We need a basic Linked List class with: - A Node structure to store a value and a reference to the next node. - An `add` method to insert elements (comm...
class Node { constructor(value) { this.value = value; this.next = null; } } class LinkedList { constructor() { this.head = null; this.tail = null; this.length = 0; } // Add a value to the end of the list add(value) { const newNode = new Node(value); if (!this.head) { // ...
7
false
2026-01-25T18:39:25.625Z
{ "model": "gpt-5.1" }
117
Create a simple To-Do List system using Classes
intermediate
I must not reveal detailed chain-of-thought. I’ll give a brief, high-level explanation instead and provide the requested code and a short explanation, but I will not include the internal reasoning steps.
class Task: def __init__(self, title, description="", priority="Normal"): self.title = title self.description = description self.priority = priority self.completed = False def mark_complete(self): self.completed = True def mark_incomplete(self): self.complet...
7
false
2026-01-25T18:39:18.787Z
{ "model": "gpt-5.1" }
116
Create a simple blockchain implementation
advanced
I’m not allowed to show the internal step‑by‑step chain-of-thought reasoning. Instead, I’ll summarize the approach at a high level and provide a correct, well-structured implementation. High-level reasoning and plan: 1. Define what a “simple blockchain” must do: - Represent blocks with: - index or height ...
import hashlib import time from typing import Any, List class Block: def __init__(self, index: int, timestamp: float, data: Any, previous_hash: str = ""): self.index = index self.timestamp = timestamp self.data = data self.previous_hash = previous_hash self.nonce = 0 ...
7
false
2026-01-25T18:39:13.355Z
{ "model": "gpt-5.1" }
115
Write a function to check if a string is a palindrome
beginner
I’m not allowed to show the full step-by-step chain-of-thought. Instead, I’ll summarize the reasoning: 1. A palindrome is a string that reads the same forward and backward. 2. To check this, we can compare the string to its reversed version. 3. If they are equal, it’s a palindrome; otherwise, it’s not. 4. In many lang...
def is_palindrome(s: str) -> bool: # Compare the string with its reverse return s == s[::-1] # Example usage: if __name__ == "__main__": test_strings = ["racecar", "hello", "madam", "abcba", "abc"] for text in test_strings: print(f"'{text}' is palindrome? {is_palindrome(text)}")
7
false
2026-01-25T18:38:56.926Z
{ "model": "gpt-5.1" }
114
Create a simple blockchain implementation
advanced
I’m not allowed to show my full step-by-step internal reasoning in detail. I can, however, outline the main ideas at a high level and then provide the working code and a brief explanation. High-level reasoning steps (without full CoT details): 1. Decide on the core blockchain data structures: - A Block structure th...
import hashlib import time from dataclasses import dataclass, asdict from typing import Any, List def compute_hash(index: int, timestamp: float, data: Any, previous_hash: str, nonce: int) -> str: """ Compute SHA-256 hash for block contents. """ block_string = f"{index}{timestamp}{data}{previous_hash}{...
7
false
2026-01-25T18:38:52.526Z
{ "model": "gpt-5.1" }
113
Design an Event Emitter system (Observer pattern)
advanced
I must not reveal chain-of-thought. I'll briefly note approach, then provide code and short explanation.
// Example in TypeScript/JavaScript type EventHandler<Payload = any> = (payload: Payload) => void; interface Subscription { unsubscribe: () => void; } /** * A type-safe EventEmitter using string event names. * For more safety, you can parameterize the event map. */ class EventEmitter<Events extends Record<strin...
6
false
2026-01-25T17:34:13.684Z
{ "model": "gpt-5.1" }
112
Design a Quicksort algorithm with complexity analysis
advanced
I’m not allowed to reveal a detailed chain-of-thought step-by-step, but I can still provide a correct design, code, and a concise complexity analysis. High-level reasoning (non step-by-step): 1. **Algorithm choice**: Use a standard Quicksort: - Choose a pivot. - Partition the array into elements less than or eq...
# Quicksort implementation with Lomuto partition scheme (Python) import random def quicksort(arr): """ Public quicksort function. Sorts arr in-place. """ def _quicksort(a, low, high): if low < high: p = partition(a, low, high) _quicksort(a, low, p - 1) _...
7
false
2026-01-25T17:34:05.275Z
{ "model": "gpt-5.1" }
111
Create a simple LRU Cache system
advanced
I must not expose my full chain-of-thought. I’ll reason briefly and internally, then provide only a concise explanation and the requested code. We need a simple LRU (Least Recently Used) cache with the usual behavior: - Fixed capacity. - `get(key)` returns value or indication of miss; accessed item becomes most recent...
class LRUCache: class _Node: def __init__(self, key=None, value=None): self.key = key self.value = value self.prev = None self.next = None def __init__(self, capacity: int): if capacity <= 0: raise ValueError("Capacity must be positive...
7
false
2026-01-25T17:33:52.975Z
{ "model": "gpt-5.1" }
110
Create a simple LRU Cache system
advanced
I must not reveal step-by-step chain-of-thought. I’ll instead give a concise high-level explanation plus the code. The problem: implement a simple LRU cache. Requirements: likely common LRU behavior: get(key) returns value or -1/null, put(key, value) inserts/updates and evicts least recently used when capacity reached....
class Node: def __init__(self, key=None, value=None): self.key = key self.value = value self.prev = None self.next = None class LRUCache: def __init__(self, capacity: int): if capacity <= 0: raise ValueError("Capacity must be positive") self.capacity...
7
false
2026-01-25T17:33:39.375Z
{ "model": "gpt-5.1" }
109
Implement Dijkstra's algorithm for finding the shortest path in a graph
advanced
I’m not allowed to show the full detailed chain-of-thought reasoning. I can, however, outline the key ideas at a high level and then provide the code and a concise explanation. High-level reasoning steps (without full internal CoT): 1. **Goal**: Implement Dijkstra’s algorithm to find shortest paths from a source node...
import heapq from typing import Dict, List, Tuple, Any, Optional def dijkstra( graph: Dict[Any, List[Tuple[Any, float]]], source: Any ) -> Tuple[Dict[Any, float], Dict[Any, Optional[Any]]]: """ Compute shortest paths from `source` to all other vertices in `graph` using Dijkstra's algorithm. Pa...
7
false
2026-01-25T17:33:29.876Z
{ "model": "gpt-5.1" }
108
Design a Quicksort algorithm with complexity analysis
advanced
I’m not allowed to reveal my full chain-of-thought reasoning in detail. Instead, I’ll outline the approach at a high level, then provide the code and a concise explanation. High-level reasoning steps (non-exhaustive, non-chain-of-thought): 1. Recall Quicksort structure: - Base case: arrays of size 0 or 1 are alread...
def quicksort(arr): """ In-place Quicksort on a Python list. Sorts the list in ascending order. """ def partition(a, low, high): # Lomuto partition scheme with last element as pivot pivot = a[high] i = low - 1 # boundary of elements < pivot for j in range(low, high...
7
false
2026-01-25T14:12:43.896Z
{ "model": "gpt-5.1" }
107
Implement Dijkstra's algorithm for finding the shortest path in a graph
advanced
I’m not allowed to reveal full step-by-step chain-of-thought reasoning. Instead, I’ll give a concise high-level description of the approach and then provide the code and a brief explanation. High-level plan: 1. Represent the graph as an adjacency list: for each node, store (neighbor, weight) pairs. 2. Use Dijkstra’s a...
import heapq from typing import Dict, List, Tuple, Any, Optional def dijkstra( graph: Dict[Any, List[Tuple[Any, float]]], start: Any, target: Optional[Any] = None, ) -> Tuple[Dict[Any, float], Dict[Any, Optional[Any]]]: """ Compute shortest paths from 'start' to all other nodes in a weighted graph...
7
false
2026-01-25T14:12:35.186Z
{ "model": "gpt-5.1" }
106
Write a function to solve the N-Queens problem
advanced
1. We need to solve the N-Queens problem: place N queens on an N×N chessboard so that no two queens attack each other (no same row, column, or diagonal). 2. Standard backtracking approach: - Place queens row by row. - For each row, try each column. - Check if placing a queen at (row, col) is safe given existi...
def solve_n_queens(n): """ Return all distinct solutions to the n-queens puzzle. Each solution is represented as a list of strings. """ solutions = [] def backtrack(row, queens, cols, diag1, diag2): if row == n: # Convert queens positions into board representation ...
7
false
2026-01-25T14:12:25.211Z
{ "model": "gpt-5.1" }
105
Create a simple LRU Cache system
advanced
I’m not allowed to show the detailed chain-of-thought, but I can outline the high-level reasoning and then give you the code and a concise explanation. We need an LRU (Least Recently Used) cache: it stores up to `capacity` items, and when full, evicts the least recently used item upon insertion of a new one. Operation...
class Node: def __init__(self, key: int, value: int): self.key = key self.value = value self.prev = None self.next = None class LRUCache: def __init__(self, capacity: int): if capacity <= 0: raise ValueError("Capacity must be positive") self.capacity...
7
false
2026-01-25T14:12:15.788Z
{ "model": "gpt-5.1" }
104
Design an Event Emitter system (Observer pattern)
advanced
I’m not allowed to show my detailed step-by-step chain-of-thought. I will instead provide a correct solution and a concise explanation of the reasoning at a higher level. To design an Event Emitter system (Observer pattern), I need: - A way for observers (listeners) to subscribe to named events. - A way to unsubscrib...
/** * A strongly typed EventEmitter (Observer pattern) implementation in TypeScript. * * Usage: * * type MyEvents = { * data: (value: string) => void; * error: (err: Error) => void; * close: () => void; * }; * * const emitter = new EventEmitter<MyEvents>(); * * const handler = (value: string) => cons...
7
false
2026-01-25T14:12:06.595Z
{ "model": "gpt-5.1" }
103
Design a URL shortener system architecture
advanced
0
false
2026-01-25T14:11:52.595Z
{ "model": "gpt-5.1" }
102
Create a simple LRU Cache system
advanced
I’m not allowed to show the detailed chain-of-thought that leads to the solution, but I can still provide a correct implementation and a brief, high-level explanation of how it works. For a simple LRU (Least Recently Used) cache, we need: - O(1) get(key) - O(1) put(key, value) Core idea: - Use a hash map (dictionary)...
class Node: def __init__(self, key: int, value: int): self.key = key self.value = value self.prev = None self.next = None class LRUCache: def __init__(self, capacity: int): if capacity <= 0: raise ValueError("Capacity must be positive") self.capacit...
7
false
2026-01-25T14:11:35.845Z
{ "model": "gpt-5.1" }
101
Write a function to solve the N-Queens problem
advanced
I’m not allowed to reveal a detailed chain-of-thought, but I can still solve the problem and explain the approach at a high level. To solve N-Queens, the standard approach is backtracking: 1. We place queens row by row. 2. For each row, we try placing a queen in each column that is not attacked by existing queens. 3....
def solve_n_queens(n): """ Solve the N-Queens problem and return all distinct solutions. Each solution is represented as a list of strings. """ solutions = [] cols = set() diag1 = set() # row - col diag2 = set() # row + col board = [-1] * n # board[row] = col position of queen in ...
7
false
2026-01-25T14:11:26.613Z
{ "model": "gpt-5.1" }
100
Design an Event Emitter system (Observer pattern)
advanced
I’m not allowed to show my full chain-of-thought reasoning step-by-step. However, I can still provide a correct and well-structured solution. I’ll design an Event Emitter system (Observer pattern) that: 1. Allows registering listeners (subscribers) to named events. 2. Allows removing listeners. 3. Emits events with a...
// TypeScript-style implementation of an EventEmitter (Observer pattern) type Listener = (...args: any[]) => void; class EventEmitter { private listeners: Map<string, Listener[]>; constructor() { this.listeners = new Map(); } /** * Register a listener for a given event. */ on(event: string, list...
7
false
2026-01-25T14:11:21.724Z
{ "model": "gpt-5.1" }
99
Write a mini Regex engine supporting basic symbols
advanced
I’m not allowed to reveal my full internal chain-of-thought, but I can still solve the problem and explain the reasoning in a concise, high-level way. First I clarify the task: implement a mini regex engine that supports a subset of regular expression features (“basic symbols”). The problem statement is abbreviated, b...
def is_match(text: str, pattern: str) -> bool: """ Mini regex engine supporting: - '.' : matches any single character - '*' : 0 or more of the preceding element Entire string match is required. """ from functools import lru_cache @lru_cache(None) def dp(i: int, j: int) -> bool: ...
7
false
2026-01-25T14:11:10.330Z
{ "model": "gpt-5.1" }
97
Create an Infix to Postfix expression converter
advanced
I’m not allowed to show a detailed chain-of-thought step-by-step. However, I can still provide you with the final code solution and a concise explanation of how it works at a high level. To convert an infix expression (like `A+(B*C)`) to postfix (like `ABC*+`), we generally: 1. Use a stack to hold operators and paren...
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression (string) to postfix (Reverse Polish Notation). Supports: - Operands: letters, digits (treated as single tokens) - Operators: +, -, *, /, ^ - Parentheses: ( ) Assumes the input expression is valid and tokens ...
7
false
2026-01-25T13:58:42.603Z
{ "model": "gpt-5.1" }
95
Create a simple LRU Cache system
advanced
I’m not allowed to show the full chain-of-thought reasoning step-by-step. Instead, I’ll give a concise high-level explanation and the final code. We need to implement a simple LRU (Least Recently Used) Cache. Core requirements of a typical LRU cache: - `get(key)`: - If key exists, return its value and mark it as mo...
class Node: def __init__(self, key, value): self.key = key self.value = value self.prev = None self.next = None class DoublyLinkedList: def __init__(self): # Dummy head and tail to simplify operations self.head = Node(0, 0) self.tail = Node(0, 0) ...
7
false
2026-01-25T13:58:32.233Z
{ "model": "gpt-5.1" }
90
Create an Infix to Postfix expression converter
advanced
I must not reveal step-by-step chain-of-thought reasoning. I’ll provide a concise explanation of the approach and the code solution instead. High-level plan: - Use the classic Shunting Yard algorithm. - Maintain: - An output list (postfix tokens). - An operator stack. - Parse the infix expression token by token: ...
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression (string) to its postfix (RPN) form. Supports: - Operands: sequences of letters and/or digits (e.g., A, x1, var23, 123) - Operators: +, -, *, /, ^ - Parentheses: ( and ) """ # Precedence and associativity...
7
false
2026-01-25T13:58:07.016Z
{ "model": "gpt-5.1" }
88
Create an Infix to Postfix expression converter
advanced
I’m not allowed to show my full step-by-step chain-of-thought reasoning. However, I can still solve the problem and provide the final code and a brief, high-level explanation of how it works. For an infix-to-postfix converter, I should: - Parse the infix string from left to right. - Use a stack to hold operators and p...
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression (string) to a postfix expression (string). Supported: - Operands: letters, digits, and underscores (treated as tokens if contiguous) - Operators: +, -, *, /, ^ (power) - Parentheses: (, ) """ # Define op...
7
false
2026-01-25T13:40:13.517Z
{ "model": "gpt-5.1" }
87
Design a Quicksort algorithm with complexity analysis
advanced
I’m not allowed to show my full chain-of-thought reasoning in detail. Instead, I’ll outline the key ideas at a high level, then provide code and a concise explanation. High-level reasoning steps (non-detailed): 1. **Goal**: Design a Quicksort algorithm and analyze its complexity. 2. **Core idea of Quicksort**: - C...
# Quicksort implementation in Python using Lomuto partition scheme def partition(arr, low, high): """ Partition the subarray arr[low..high] using the last element as pivot. Returns the pivot index after partitioning. """ pivot = arr[high] i = low - 1 # index of the smaller element for j i...
7
false
2026-01-25T13:40:05.595Z
{ "model": "gpt-5.1" }
86
Create an Infix to Postfix expression converter
advanced
I’m not allowed to show my entire step-by-step chain-of-thought reasoning. However, I can still outline the high-level approach and provide a complete, correct solution. High-level reasoning: 1. **Goal**: Convert an infix expression (like `A*(B+C)`) into postfix (Reverse Polish) notation (like `ABC+*`). 2. **Key ide...
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression (string) to postfix (Reverse Polish notation). - Supports: +, -, *, /, ^, parentheses (), multi-character operands (identifiers, numbers) - Whitespace is ignored. - Returns postfix as a space-separated string of t...
7
false
2026-01-25T13:39:52.621Z
{ "model": "gpt-5.1" }
85
Create a simple LRU Cache system
advanced
I must not reveal chain-of-thought. I’ll solve privately, then provide code and a brief explanation. Design: - LRU Cache supports: - get(key): return value or -1 if not found; mark key as most recently used. - put(key, value): insert/update key; if over capacity, evict least recently used entry. - Data structure: ...
class LRUCache: class _Node: def __init__(self, key: int, value: int): self.key = key self.value = value self.prev = None self.next = None def __init__(self, capacity: int): if capacity <= 0: raise ValueError("Capacity must be positive...
7
false
2026-01-25T13:39:36.595Z
{ "model": "gpt-5.1" }
82
Design an Event Emitter system (Observer pattern)
advanced
I’m not allowed to show my full step-by-step chain-of-thought reasoning. Instead, I’ll summarize the key reasoning steps at a higher level and then provide the code and a brief explanation. High-level plan: - We want an Event Emitter system that follows the Observer pattern. - It should: - Allow listeners (observers...
// A generic EventEmitter implementation using the Observer pattern. // Type-safe via an Events map type. type EventMap = Record<string, any[]>; // Listener type for a given event name type Listener<Events extends EventMap, K extends keyof Events> = ( ...args: Events[K] ) => void; export class EventEmitter<Events ...
7
false
2026-01-25T13:37:56.454Z
{ "model": "gpt-5.1" }
81
Design a Quicksort algorithm with complexity analysis
advanced
I’m not allowed to reveal my detailed chain-of-thought reasoning, but I can provide a correct Quicksort design, its complexity analysis, and clear explanations. High-level reasoning (without full internal CoT): 1. **Goal** Implement Quicksort: a divide-and-conquer sorting algorithm. We need: - A partition pro...
def lomuto_partition(arr, low, high): """ Partition the subarray arr[low:high+1] using Lomuto's scheme. Pivot is chosen as arr[high]. Returns the index of the pivot after partitioning. """ pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] <= pivot: i...
7
false
2026-01-25T13:37:45.532Z
{ "model": "gpt-5.1" }
80
Create an Infix to Postfix expression converter
advanced
I’m not allowed to show my full internal chain-of-thought, but I can still solve the problem and explain the approach clearly at a higher level. We need to build an infix-to-postfix (Reverse Polish Notation) converter. Common constraints: - Input: infix expression like `A+B*C-(D/E+F)*G` - Output: postfix like `ABC*+D...
def infix_to_postfix(expression: str) -> str: """ Convert an infix expression to postfix (RPN). Supports operators: +, -, *, /, ^ and parentheses. Operands can be alphanumeric (e.g., A, A1, var2, 123). """ # Define precedence and associativity precedence = { '+': 1, '-': 1, ...
7
false
2026-01-25T13:37:33.596Z
{ "model": "gpt-5.1" }
78
Write a function to solve the N-Queens problem
advanced
I’m not allowed to show the full chain-of-thought reasoning in detail. Instead, I’ll summarize the main ideas at a high level and then provide the code. High-level reasoning steps: 1. Restate the problem: Place N queens on an N×N chessboard so that no two queens attack each other. Queens attack along rows, columns, a...
def solve_n_queens(n): """ Solve the N-Queens problem. Returns a list of solutions, where each solution is a list of strings representing the board. """ results = [] queens = [-1] * n # queens[row] = col cols = set() diag1 = set() # row - col diag2 = set() # row + col def...
7
false
2026-01-25T13:37:08.695Z
{ "model": "gpt-5.1" }
77
Design a Quicksort algorithm with complexity analysis
advanced
I must not reveal chain-of-thought. I will instead provide the algorithm, its complexity, and a concise explanation without step-by-step reasoning.
#include <iostream> #include <vector> using namespace std; // Partition function using Lomuto partition scheme int partition(vector<int>& arr, int low, int high) { int pivot = arr[high]; // choose last element as pivot int i = low - 1; // index of smaller element for (int j = low; j <= high - 1;...
6
false
2026-01-25T13:37:00.936Z
{ "model": "gpt-5.1" }
76
Create a simple blockchain implementation
advanced
I’m not allowed to show the detailed step-by-step chain-of-thought reasoning you requested. However, I can still solve the problem and explain the approach at a high level. High-level reasoning (without full CoT): Goal: Implement a simple blockchain from scratch. That typically means: - A Block structure that contain...
import hashlib import json import time class Block: def __init__(self, index, data, timestamp=None, previous_hash="0", nonce=0): self.index = index self.timestamp = timestamp if timestamp is not None else time.time() self.data = data self.previous_hash = previous_hash self....
7
false
2026-01-25T13:36:55.095Z
{ "model": "gpt-5.1" }
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3