Jonttup commited on
Commit
049ca2e
·
verified ·
1 Parent(s): 91c4af0

Upload e1_results_v2.json with huggingface_hub

Browse files
Files changed (1) hide show
  1. e1_results_v2.json +446 -0
e1_results_v2.json ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "google/diffusiongemma-26B-A4B-it",
3
+ "n_tasks": 22,
4
+ "config": {
5
+ "max_blocks": 16,
6
+ "max_resample": 4,
7
+ "dtype": "torch.bfloat16",
8
+ "extraction": true,
9
+ "instruction": "raw-code"
10
+ },
11
+ "headline_metric": "final_valid = ast.parse of the EXTRACTED program",
12
+ "vanilla": {
13
+ "final_valid": 0.955,
14
+ "valid_block_rate": 0.909,
15
+ "n_blocks": 1.182,
16
+ "total_denoisings": 1.182,
17
+ "wall_s": 2.254
18
+ },
19
+ "verified": {
20
+ "final_valid": 1.0,
21
+ "valid_block_rate": 0.977,
22
+ "n_blocks": 1.182,
23
+ "total_denoisings": 1.5,
24
+ "wall_s": 2.859
25
+ },
26
+ "tasks": [
27
+ {
28
+ "task": "a `LRUCache` class with `__init__(capacity)`, `get(key)`, and `put(key, value)` using an OrderedDict, with capacity eviction",
29
+ "vanilla": {
30
+ "final_valid": true,
31
+ "valid_block_rate": 1.0,
32
+ "n_blocks": 1,
33
+ "total_denoisings": 1,
34
+ "wall_s": 7.19,
35
+ "code": "from collections import OrderedDict\n\nclass LRUCache:\n def __init__(self, capacity: int):\n self.capacity = capacity\n self.cache = OrderedDict()\n\n def get(self, key: int) -> int:\n if key not in self.cache:\n return -1\n self.cache.move_to_end(key)\n return self.cache[key]\n\n def put(self, key: int, value: int) -> None:\n if key in self.cache:\n self.cache.move_to_end(key)\n self.cache[key] = value\n if len(self.cache) > self.capacity:\n self.cache.popitem(last=False)"
36
+ },
37
+ "verified": {
38
+ "final_valid": true,
39
+ "valid_block_rate": 1.0,
40
+ "n_blocks": 1,
41
+ "total_denoisings": 1,
42
+ "wall_s": 1.29,
43
+ "code": "from collections import OrderedDict\n\nclass LRUCache:\n def __init__(self, capacity: int):\n self.capacity = capacity\n self.cache = OrderedDict()\n\n def get(self, key: int) -> int:\n if key not in self.cache:\n return -1\n self.cache.move_to_end(key)\n return self.cache[key]\n\n def put(self, key: int, value: int) -> None:\n if key in self.cache:\n self.cache.move_to_end(key)\n self.cache[key] = value\n if len(self.cache) > self.capacity:\n self.cache.popitem(last=False)"
44
+ }
45
+ },
46
+ {
47
+ "task": "a `class BankAccount` with a `@property balance`, `deposit`, `withdraw` raising `ValueError` on overdraft, and a `__repr__`",
48
+ "vanilla": {
49
+ "final_valid": true,
50
+ "valid_block_rate": 1.0,
51
+ "n_blocks": 1,
52
+ "total_denoisings": 1,
53
+ "wall_s": 1.0,
54
+ "code": "class BankAccount:\n def __init__(self, initial_balance=0):\n self._balance = initial_balance\n\n @property\n def balance(self):\n return self._balance\n\n def deposit(self, amount):\n if amount <= 0:\n raise ValueError(\"Deposit amount must be positive\")\n self._balance += amount\n\n def withdraw(self, amount):\n if amount <= 0:\n raise ValueError(\"Withdrawal amount must be positive\")\n if amount > self._balance:\n raise ValueError(\"Insufficient funds\")\n self._balance -= amount\n\n def __repr__(self):\n return f\"BankAccount(balance={self._balance})\""
55
+ },
56
+ "verified": {
57
+ "final_valid": true,
58
+ "valid_block_rate": 1.0,
59
+ "n_blocks": 1,
60
+ "total_denoisings": 1,
61
+ "wall_s": 1.0,
62
+ "code": "class BankAccount:\n def __init__(self, initial_balance=0):\n self._balance = initial_balance\n\n @property\n def balance(self):\n return self._balance\n\n def deposit(self, amount):\n if amount <= 0:\n raise ValueError(\"Deposit amount must be positive\")\n self._balance += amount\n\n def withdraw(self, amount):\n if amount <= 0:\n raise ValueError(\"Withdrawal amount must be positive\")\n if amount > self._balance:\n raise ValueError(\"Insufficient funds\")\n self._balance -= amount\n\n def __repr__(self):\n return f\"BankAccount(balance={self._balance})\""
63
+ }
64
+ },
65
+ {
66
+ "task": "a recursive descent parser for arithmetic expressions (+ - * / and parentheses) as a function `evaluate(expr: str) -> float`",
67
+ "vanilla": {
68
+ "final_valid": true,
69
+ "valid_block_rate": 1.0,
70
+ "n_blocks": 2,
71
+ "total_denoisings": 2,
72
+ "wall_s": 2.2,
73
+ "code": "import re\n\ndef evaluate(expr: str) -> float:\n tokens = re.findall(r'\\d+\\.?\\d*|[+\\-*/()-()]', expr)\n pos = 0\n\n def peek():\n return tokens[pos] if pos < len(tokens) else None\n\n def consume():\n nonlocal pos\n token = peek()\n pos += 1\n return token\n\n def expression():\n node = term()\n while peek() in ('+', '-'):\n op = consume()\n right = term()\n if op == '+':\n node += right\n else:\n node -= right\n return node\n\n def term():\n node = factor()\n while peek() in ('*', '/'):\n op = consume()\n right = factor()\n if op == '*':\n node *= right\n else:\n node /= right\n return node\n\n def factor():\n token = consume()\n if token == '(':\n result = expression()\n consume() # consume ')'\n return result\n return float(token)\n\n return expression()"
74
+ },
75
+ "verified": {
76
+ "final_valid": true,
77
+ "valid_block_rate": 1.0,
78
+ "n_blocks": 2,
79
+ "total_denoisings": 2,
80
+ "wall_s": 2.2,
81
+ "code": "import re\n\ndef evaluate(expr: str) -> float:\n tokens = re.findall(r'\\d+\\.?\\d*|[+\\-*/()-()]', expr)\n pos = 0\n\n def peek():\n return tokens[pos] if pos < len(tokens) else None\n\n def consume():\n nonlocal pos\n token = peek()\n pos += 1\n return token\n\n def expression():\n node = term()\n while peek() in ('+', '-'):\n op = consume()\n right = term()\n if op == '+':\n node += right\n else:\n node -= right\n return node\n\n def term():\n node = factor()\n while peek() in ('*', '/'):\n op = consume()\n right = factor()\n if op == '*':\n node *= right\n else:\n node /= right\n return node\n\n def factor():\n token = consume()\n if token == '(':\n result = expression()\n consume() # consume ')'\n return result\n return float(token)\n\n return expression()"
82
+ }
83
+ },
84
+ {
85
+ "task": "a `@dataclass(frozen=True)` `Vector3` with `__add__`, `__mul__` (scalar), `dot`, `cross`, and `norm` methods and type hints",
86
+ "vanilla": {
87
+ "final_valid": true,
88
+ "valid_block_rate": 1.0,
89
+ "n_blocks": 2,
90
+ "total_denoisings": 2,
91
+ "wall_s": 1.43,
92
+ "code": "from dataclasses import dataclass\nimport math\n\n@dataclass(frozen=True)\nclass Vector3:\n x: float\n y: float\n z: float\n\n def __add__(self, other: 'Vector3') -> 'Vector3':\n return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)\n\n def __mul__(self, scalar: float) -> 'Vector3':\n return Vector3(self.x * scalar, self.y * scalar, self.z * scalar)\n\n def dot(self, other: 'Vector3') -> float:\n return self.x * other.x + self.y * other.y + self.z * other.z\n\n def cross(self, other: 'Vector3') -> 'Vector3':\n return Vector3(\n self.y * other.z - self.z * other.y,\n self.z * other.x - self.x * other.z,\n self.x * other.y - self.y * other.x\n )\n\n def norm(self) -> float:\n return math.sqrt(self.dot(self))"
93
+ },
94
+ "verified": {
95
+ "final_valid": true,
96
+ "valid_block_rate": 1.0,
97
+ "n_blocks": 2,
98
+ "total_denoisings": 2,
99
+ "wall_s": 1.43,
100
+ "code": "from dataclasses import dataclass\nimport math\n\n@dataclass(frozen=True)\nclass Vector3:\n x: float\n y: float\n z: float\n\n def __add__(self, other: 'Vector3') -> 'Vector3':\n return Vector3(self.x + other.x, self.y + other.y, self.z + other.z)\n\n def __mul__(self, scalar: float) -> 'Vector3':\n return Vector3(self.x * scalar, self.y * scalar, self.z * scalar)\n\n def dot(self, other: 'Vector3') -> float:\n return self.x * other.x + self.y * other.y + self.z * other.z\n\n def cross(self, other: 'Vector3') -> 'Vector3':\n return Vector3(\n self.y * other.z - self.z * other.y,\n self.z * other.x - self.x * other.z,\n self.x * other.y - self.y * other.x\n )\n\n def norm(self) -> float:\n return math.sqrt(self.dot(self))"
101
+ }
102
+ },
103
+ {
104
+ "task": "a decorator `@retry(times, exceptions)` that retries the wrapped function, and an example function using it",
105
+ "vanilla": {
106
+ "final_valid": true,
107
+ "valid_block_rate": 1.0,
108
+ "n_blocks": 1,
109
+ "total_denoisings": 1,
110
+ "wall_s": 2.66,
111
+ "code": "import functools\n\ndef retry(times, exceptions):\n def decorator(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n last_exception = None\n for i in range(times):\n try:\n return func(*args, **kwargs)\n except exceptions as e:\n last_exception = e\n print(f\"Attempt {i + 1} failed: {e}\")\n raise last_exception\n return wrapper\n return decorator\n\n@retry(times=3, exceptions=(ValueError, ZeroDivisionError))\ndef unstable_function(n):\n import random\n if random.random() < 0.7:\n raise ValueError(\"Random failure occurred\")\n return n * 2\n\nif __name__ == \"__main__\":\n try:\n result = unstable_function(10)\n print(f\"Result: {result}\")\n except ValueError as e:\n print(f\"Function failed after all retries: {e}\")"
112
+ },
113
+ "verified": {
114
+ "final_valid": true,
115
+ "valid_block_rate": 1.0,
116
+ "n_blocks": 1,
117
+ "total_denoisings": 1,
118
+ "wall_s": 2.66,
119
+ "code": "import functools\n\ndef retry(times, exceptions):\n def decorator(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n last_exception = None\n for i in range(times):\n try:\n return func(*args, **kwargs)\n except exceptions as e:\n last_exception = e\n print(f\"Attempt {i + 1} failed: {e}\")\n raise last_exception\n return wrapper\n return decorator\n\n@retry(times=3, exceptions=(ValueError, ZeroDivisionError))\ndef unstable_function(n):\n import random\n if random.random() < 0.7:\n raise ValueError(\"Random failure occurred\")\n return n * 2\n\nif __name__ == \"__main__\":\n try:\n result = unstable_function(10)\n print(f\"Result: {result}\")\n except ValueError as e:\n print(f\"Function failed after all retries: {e}\")"
120
+ }
121
+ },
122
+ {
123
+ "task": "an async function `fetch_all(urls)` using `asyncio.gather` and a semaphore to limit concurrency to 5, with type hints",
124
+ "vanilla": {
125
+ "final_valid": true,
126
+ "valid_block_rate": 1.0,
127
+ "n_blocks": 1,
128
+ "total_denoisings": 1,
129
+ "wall_s": 1.76,
130
+ "code": "import asyncio\nimport httpx\nfrom typing import List, Any\n\nasync def fetch_url(url: str, semaphore: asyncio.Semaphore, client: httpx.AsyncClient) -> Any:\n async with semaphore:\n response = await client.get(url)\n return response.text\n\nasync def fetch_all(urls: List[str]) -> List[Any]:\n semaphore = asyncio.Semaphore(5)\n async with httpx.AsyncClient() as client:\n tasks = [fetch_url(url, semaphore, client) for url in urls]\n results = await asyncio.gather(*tasks)\n return list(results)"
131
+ },
132
+ "verified": {
133
+ "final_valid": true,
134
+ "valid_block_rate": 1.0,
135
+ "n_blocks": 1,
136
+ "total_denoisings": 1,
137
+ "wall_s": 1.76,
138
+ "code": "import asyncio\nimport httpx\nfrom typing import List, Any\n\nasync def fetch_url(url: str, semaphore: asyncio.Semaphore, client: httpx.AsyncClient) -> Any:\n async with semaphore:\n response = await client.get(url)\n return response.text\n\nasync def fetch_all(urls: List[str]) -> List[Any]:\n semaphore = asyncio.Semaphore(5)\n async with httpx.AsyncClient() as client:\n tasks = [fetch_url(url, semaphore, client) for url in urls]\n results = await asyncio.gather(*tasks)\n return list(results)"
139
+ }
140
+ },
141
+ {
142
+ "task": "a generator function `sliding_window(iterable, n)` yielding tuples of length n, plus a `flatten(nested)` recursive generator",
143
+ "vanilla": {
144
+ "final_valid": true,
145
+ "valid_block_rate": 1.0,
146
+ "n_blocks": 1,
147
+ "total_denoisings": 1,
148
+ "wall_s": 1.12,
149
+ "code": "def sliding_window(iterable, n):\n it = iter(iterable)\n window = []\n for _ in range(n):\n try:\n window.append(next(it))\n except StopIteration:\n return\n yield tuple(window)\n for item in it:\n window.pop(0)\n window.append(item)\n yield tuple(window)\n\ndef flatten(nested):\n for item in nested:\n if isinstance(item, (list, tuple)):\n yield from flatten(item)\n else:\n yield item"
150
+ },
151
+ "verified": {
152
+ "final_valid": true,
153
+ "valid_block_rate": 1.0,
154
+ "n_blocks": 1,
155
+ "total_denoisings": 1,
156
+ "wall_s": 1.13,
157
+ "code": "def sliding_window(iterable, n):\n it = iter(iterable)\n window = []\n for _ in range(n):\n try:\n window.append(next(it))\n except StopIteration:\n return\n yield tuple(window)\n for item in it:\n window.pop(0)\n window.append(item)\n yield tuple(window)\n\ndef flatten(nested):\n for item in nested:\n if isinstance(item, (list, tuple)):\n yield from flatten(item)\n else:\n yield item"
158
+ }
159
+ },
160
+ {
161
+ "task": "a `merge_sort(xs)` and a `quicksort(xs)` in one module, both pure functions with docstrings",
162
+ "vanilla": {
163
+ "final_valid": true,
164
+ "valid_block_rate": 0.5,
165
+ "n_blocks": 2,
166
+ "total_denoisings": 2,
167
+ "wall_s": 2.01,
168
+ "code": "def merge_sort(xs):\n \"\"\"\n Sorts a list using the merge sort algorithm.\n \n Args:\n xs (list): A list of comparable elements.\n \n Returns:\n list: A new list containing the elements in ascending order.\n \"\"\"\n if len(xs) <= 1:\n return xs\n \n mid = len(xs) // 2\n left = merge_sort(xs[:mid])\n right = merge_sort(xs[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n result.extend(left[i:])\n result.extend(right[j:])\n return result\n\ndef quicksort(xs):\n \"\"\"\n Sorts a list using the quicksort algorithm.\n \n Args:\n xs (list): A list of comparable elements.\n \n Returns:\n list: A new list containing the elements in ascending order.\n \"\"\"\n if len(xs) <= 1:\n return xs\n \n pivot = xs[len(xs) // 2]\n left = [x for x in xs if x < pivot]\n middle = [x for x in xs if x == pivot]\n right = [x for x in xs if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)"
169
+ },
170
+ "verified": {
171
+ "final_valid": true,
172
+ "valid_block_rate": 0.5,
173
+ "n_blocks": 2,
174
+ "total_denoisings": 6,
175
+ "wall_s": 9.28,
176
+ "code": "def merge_sort(xs):\n \"\"\"\n Sorts a list using the merge sort algorithm.\n \n Args:\n xs (list): A list of comparable elements.\n \n Returns:\n list: A new list containing the elements in ascending order.\n \"\"\"\n if len(xs) <= 1:\n return xs\n \n mid = len(xs) // 2\n left = merge_sort(xs[:mid])\n right = merge_sort(xs[mid:])\n \n return merge(left, right)\n\ndef merge(left, right):\n result = []\n i = j = 0\n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n result.append(left[i])\n i += 1\n else:\n result.append(right[j])\n j += 1\n result.extend(left[i:])\n result.extend(right[j:])\n return result\n\ndef quicksort(xs):\n \"\"\"\n Sorts a list using the quicksort algorithm.\n \n Args:\n xs (list): A list of comparable elements.\n \n Returns:\n list: A new list containing the elements in ascending order.\n \"\"\"\n if len(xs) <= 1:\n return xs\n \n pivot = xs[len(xs) // 2]\n left = [x for x in xs if x < pivot]\n middle = [x for x in xs if x == pivot]\n right = [x for x in xs if x > pivot]\n \n return quicksort(left) + middle + quicksort(right)"
177
+ }
178
+ },
179
+ {
180
+ "task": "a context manager class `Timer` using `__enter__`/`__exit__` that prints elapsed ms, and a `@contextmanager` version too",
181
+ "vanilla": {
182
+ "final_valid": true,
183
+ "valid_block_rate": 1.0,
184
+ "n_blocks": 1,
185
+ "total_denoisings": 1,
186
+ "wall_s": 1.15,
187
+ "code": "import time\nfrom contextlib import contextmanager\n\nclass Timer:\n def __enter__(self):\n self.start_time = time.perf_counter()\n return self\n\n def __exit__(self, exc_type, exc_val, exc_tb):\n end_time = time.perf_counter()\n elapsed = (end_time - self.start_time) * 1000\n print(f\"Elapsed time: {elapsed:.2f} ms\")\n\n@contextmanager\ndef timer_context():\n start_time = time.perf_counter()\n try:\n yield\n finally:\n end_time = time.perf_counter()\n elapsed = (end_time - start_time) * 1000\n print(f\"Elapsed time: {elapsed:.2f} ms\")"
188
+ },
189
+ "verified": {
190
+ "final_valid": true,
191
+ "valid_block_rate": 1.0,
192
+ "n_blocks": 1,
193
+ "total_denoisings": 1,
194
+ "wall_s": 1.14,
195
+ "code": "import time\nfrom contextlib import contextmanager\n\nclass Timer:\n def __enter__(self):\n self.start_time = time.perf_counter()\n return self\n\n def __exit__(self, exc_type, exc_val, exc_tb):\n end_time = time.perf_counter()\n elapsed = (end_time - self.start_time) * 1000\n print(f\"Elapsed time: {elapsed:.2f} ms\")\n\n@contextmanager\ndef timer_context():\n start_time = time.perf_counter()\n try:\n yield\n finally:\n end_time = time.perf_counter()\n elapsed = (end_time - start_time) * 1000\n print(f\"Elapsed time: {elapsed:.2f} ms\")"
196
+ }
197
+ },
198
+ {
199
+ "task": "a function `group_by(items, key)` returning a dict, using `collections.defaultdict`, with a nested list/dict comprehension example",
200
+ "vanilla": {
201
+ "final_valid": true,
202
+ "valid_block_rate": 1.0,
203
+ "n_blocks": 1,
204
+ "total_denoisings": 1,
205
+ "wall_s": 2.01,
206
+ "code": "from collections import defaultdict\n\ndef group_by(items, key):\n result = defaultdict(list)\n for item in items:\n result[key(item)].append(item)\n return dict(result)\n\n# Example using nested comprehension to process data\ndata = [\n {'name': 'apple', 'type': 'fruit'},\n {'name': 'carrot', 'type': 'vegetable'},\n {'name': 'banana', 'type': 'fruit'},\n {'name': 'broccoli', 'type': 'vegetable'}\n]\n\ngrouped = group_by(data, lambda x: x['type'])\n\n# Nested comprehension example to transform grouped data\noutput = {\n k: [item['name'] for item in v] \n for k, v in grouped.items()\n}\n\nprint(output)"
207
+ },
208
+ "verified": {
209
+ "final_valid": true,
210
+ "valid_block_rate": 1.0,
211
+ "n_blocks": 1,
212
+ "total_denoisings": 1,
213
+ "wall_s": 2.03,
214
+ "code": "from collections import defaultdict\n\ndef group_by(items, key):\n result = defaultdict(list)\n for item in items:\n result[key(item)].append(item)\n return dict(result)\n\n# Example using nested comprehension to process data\ndata = [\n {'name': 'apple', 'type': 'fruit'},\n {'name': 'carrot', 'type': 'vegetable'},\n {'name': 'banana', 'type': 'fruit'},\n {'name': 'broccoli', 'type': 'vegetable'}\n]\n\ngrouped = group_by(data, lambda x: x['type'])\n\n# Nested comprehension example to transform grouped data\noutput = {\n k: [item['name'] for item in v] \n for k, v in grouped.items()\n}\n\nprint(output)"
215
+ }
216
+ },
217
+ {
218
+ "task": "a `class Trie` supporting `insert(word)`, `search(word)`, and `starts_with(prefix)` with nested dict nodes",
219
+ "vanilla": {
220
+ "final_valid": true,
221
+ "valid_block_rate": 1.0,
222
+ "n_blocks": 1,
223
+ "total_denoisings": 1,
224
+ "wall_s": 0.96,
225
+ "code": "class Trie:\n def __init__(self):\n self.root = {}\n\n def insert(self, word: str):\n node = self.root\n for char in word:\n if char not in node:\n node[char] = {}\n node = node[char]\n node['#'] = True\n\n def search(self, word: str) -> bool:\n node = self.root\n for char in word:\n if char not in node:\n return False\n node = node[char]\n return '#' in node\n\n def starts_with(self, prefix: str) -> bool:\n node = self.root\n for char in prefix:\n if char not in node:\n return False\n node = node[char]\n return True"
226
+ },
227
+ "verified": {
228
+ "final_valid": true,
229
+ "valid_block_rate": 1.0,
230
+ "n_blocks": 1,
231
+ "total_denoisings": 1,
232
+ "wall_s": 0.97,
233
+ "code": "class Trie:\n def __init__(self):\n self.root = {}\n\n def insert(self, word: str):\n node = self.root\n for char in word:\n if char not in node:\n node[char] = {}\n node = node[char]\n node['#'] = True\n\n def search(self, word: str) -> bool:\n node = self.root\n for char in word:\n if char not in node:\n return False\n node = node[char]\n return '#' in node\n\n def starts_with(self, prefix: str) -> bool:\n node = self.root\n for char in prefix:\n if char not in node:\n return False\n node = node[char]\n return True"
234
+ }
235
+ },
236
+ {
237
+ "task": "a `dijkstra(graph, start)` shortest-path function using `heapq`, returning a dict of distances, with type hints `dict[str, dict[str, int]]`",
238
+ "vanilla": {
239
+ "final_valid": true,
240
+ "valid_block_rate": 1.0,
241
+ "n_blocks": 1,
242
+ "total_denoisings": 1,
243
+ "wall_s": 1.62,
244
+ "code": "import heapq\n\ndef dijkstra(graph: dict[str, dict[str, int]], start: str) -> dict[str, int]:\n distances = {node: float('inf') for node in graph}\n distances[start] = 0\n queue = [(0, start)]\n\n while queue:\n current_distance, current_node = heapq.heappop(queue)\n\n if current_distance > distances[current_node]:\n continue\n\n for neighbor, weight in graph[current_node].items():\n distance = current_distance + weight\n if distance < distances[neighbor]:\n distances[neighbor] = distance\n heapq.heappush(queue, (distance, neighbor))\n\n return {node: int(dist) if dist != float('inf') else dist for node, dist in distances.items()}"
245
+ },
246
+ "verified": {
247
+ "final_valid": true,
248
+ "valid_block_rate": 1.0,
249
+ "n_blocks": 1,
250
+ "total_denoisings": 1,
251
+ "wall_s": 1.83,
252
+ "code": "import heapq\n\ndef dijkstra(graph: dict[str, dict[str, int]], start: str) -> dict[str, int]:\n distances = {node: float('inf') for node in graph}\n distances[start] = 0\n queue = [(0, start)]\n\n while queue:\n current_distance, current_node = heapq.heappop(queue)\n\n if current_distance > distances[current_node]:\n continue\n\n for neighbor, weight in graph[current_node].items():\n distance = current_distance + weight\n if distance < distances[neighbor]:\n distances[neighbor] = distance\n heapq.heappush(queue, (distance, neighbor))\n\n return {node: int(dist) if dist != float('inf') else dist for node, dist in distances.items()}"
253
+ }
254
+ },
255
+ {
256
+ "task": "a function using structural pattern matching (`match`/`case`) to evaluate a nested AST of tuples like `('+', 1, ('*', 2, 3))`",
257
+ "vanilla": {
258
+ "final_valid": true,
259
+ "valid_block_rate": 1.0,
260
+ "n_blocks": 1,
261
+ "total_denoisings": 1,
262
+ "wall_s": 1.76,
263
+ "code": "def evaluate(node):\n match node:\n case int() | float():\n return node\n case ('+', left, right):\n return evaluate(left) + evaluate(right)\n case ('-', left, right):\n return evaluate(left) - evaluate(right)\n case ('*', left, right):\n return evaluate(left) * evaluate(right)\n case ('/', left, right):\n return evaluate(left) / evaluate(right)\n case _:\n raise ValueError(f\"Invalid AST node: {node}\")"
264
+ },
265
+ "verified": {
266
+ "final_valid": true,
267
+ "valid_block_rate": 1.0,
268
+ "n_blocks": 1,
269
+ "total_denoisings": 1,
270
+ "wall_s": 1.85,
271
+ "code": "def evaluate(node):\n match node:\n case int() | float():\n return node\n case ('+', left, right):\n return evaluate(left) + evaluate(right)\n case ('-', left, right):\n return evaluate(left) - evaluate(right)\n case ('*', left, right):\n return evaluate(left) * evaluate(right)\n case ('/', left, right):\n return evaluate(left) / evaluate(right)\n case _:\n raise ValueError(f\"Invalid AST node: {node}\")"
272
+ }
273
+ },
274
+ {
275
+ "task": "a `class EventEmitter` with `on(event, handler)`, `off(event, handler)`, and `emit(event, *args, **kwargs)` using a defaultdict of lists",
276
+ "vanilla": {
277
+ "final_valid": true,
278
+ "valid_block_rate": 1.0,
279
+ "n_blocks": 1,
280
+ "total_denoisings": 1,
281
+ "wall_s": 1.15,
282
+ "code": "from collections import defaultdict\n\nclass EventEmitter:\n def __init__(self):\n self.events = defaultdict(list)\n\n def on(self, event, handler):\n self.events[event].append(handler)\n\n def off(self, event, handler):\n if event in self.events:\n try:\n self.events[event].remove(handler)\n except ValueError:\n pass\n\n def emit(self, event, *args, **kwargs):\n if event in self.events:\n for handler in self.events[event]:\n handler(*args, **kwargs)"
283
+ },
284
+ "verified": {
285
+ "final_valid": true,
286
+ "valid_block_rate": 1.0,
287
+ "n_blocks": 1,
288
+ "total_denoisings": 1,
289
+ "wall_s": 1.08,
290
+ "code": "from collections import defaultdict\n\nclass EventEmitter:\n def __init__(self):\n self.events = defaultdict(list)\n\n def on(self, event, handler):\n self.events[event].append(handler)\n\n def off(self, event, handler):\n if event in self.events:\n try:\n self.events[event].remove(handler)\n except ValueError:\n pass\n\n def emit(self, event, *args, **kwargs):\n if event in self.events:\n for handler in self.events[event]:\n handler(*args, **kwargs)"
291
+ }
292
+ },
293
+ {
294
+ "task": "a function `parse_ini(text)` returning a nested dict of sections, handling comments and `key = value`, with a walrus operator somewhere",
295
+ "vanilla": {
296
+ "final_valid": true,
297
+ "valid_block_rate": 1.0,
298
+ "n_blocks": 1,
299
+ "total_denoisings": 1,
300
+ "wall_s": 3.22,
301
+ "code": "import re\n\ndef parse_ini(text):\n result = {}\n current_section = None\n for line in text.splitlines():\n line = line.strip()\n if not line or line.startswith(('#', ';')):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n result[current_section] = {}\n elif '=' in line and current_section is not None:\n key, value = line.split('=', 1)\n result[current_section][key.strip()] = value.strip()\n return result"
302
+ },
303
+ "verified": {
304
+ "final_valid": true,
305
+ "valid_block_rate": 1.0,
306
+ "n_blocks": 1,
307
+ "total_denoisings": 1,
308
+ "wall_s": 2.63,
309
+ "code": "import re\n\ndef parse_ini(text):\n result = {}\n current_section = None\n for line in text.splitlines():\n line = line.strip()\n if not line or line.startswith(('#', ';')):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n result[current_section] = {}\n elif '=' in line and current_section is not None:\n key, value = line.split('=', 1)\n result[current_section][key.strip()] = value.strip()\n return result"
310
+ }
311
+ },
312
+ {
313
+ "task": "a `class Matrix` wrapping a list of lists with `__matmul__`, `transpose`, and `__getitem__` accepting a `(row, col)` tuple",
314
+ "vanilla": {
315
+ "final_valid": true,
316
+ "valid_block_rate": 0.5,
317
+ "n_blocks": 2,
318
+ "total_denoisings": 2,
319
+ "wall_s": 1.86,
320
+ "code": "class Matrix:\n def __init__(self, data):\n self.data = data\n self.rows = len(data)\n self.cols = len(data[0]) if self.rows > 0 else 0\n\n def __getitem__(self, key):\n row, col = key\n return self.data[row][col]\n\n def transpose(self):\n new_data = [[self.data[r][c] for r in range(self.rows)] for c in range(self.cols)]\n return Matrix(new_data)\n\n def __matmul__(self, other):\n if self.cols != other.rows:\n raise ValueError(\"Incompatible dimensions for multiplication\")\n new_data = []\n for i in range(self.rows):\n row = []\n for j in range(other.cols):\n element = sum(self.data[i][k] * other.data[k][j] for k in range(self.cols))\n row.append(element)\n new_data.append(row)\n return Matrix(new_data)"
321
+ },
322
+ "verified": {
323
+ "final_valid": true,
324
+ "valid_block_rate": 1.0,
325
+ "n_blocks": 2,
326
+ "total_denoisings": 4,
327
+ "wall_s": 5.53,
328
+ "code": "class Matrix:\n def __init__(self, data):\n self.data = data\n self.rows = len(data)\n self.cols = len(data[0]) if self.rows > 0 else 0\n\n def __getitem__(self, key):\n row, col = key\n return self.data[row][col]\n\n def transpose(self):\n new_data = [[self.data[r][c] for r in range(self.rows)] for c in range(self.cols)]\n return Matrix(new_data)\n\n def __matmul__(self, other):\n if self.cols != other.rows:\n raise ValueError(\"Incompatible dimensions\")\n new_data = []\n for i in range(self.rows):\n new_row = []\n for j in range(other.cols):\n element = sum(self.data[i][k] * other.data[k][j] for k in range(self.cols))\n new_row.append(element)\n new_data.append(new_row)\n return Matrix(new_data)\n\n def __repr__(self):\n return f\"Matrix({self.data})\""
329
+ }
330
+ },
331
+ {
332
+ "task": "a `memoize` decorator using `functools.wraps` and a dict cache keyed by args, applied to a recursive `fib`",
333
+ "vanilla": {
334
+ "final_valid": true,
335
+ "valid_block_rate": 1.0,
336
+ "n_blocks": 1,
337
+ "total_denoisings": 1,
338
+ "wall_s": 1.05,
339
+ "code": "import functools\n\ndef memoize(func):\n cache = {}\n @functools.wraps(func)\n def wrapper(*args):\n if args not in cache:\n cache[args] = func(*args)\n return cache[args]\n return wrapper\n\n@memoize\ndef fib(n):\n if n < 2:\n return n\n return fib(n - 1) + fib(n - 2)"
340
+ },
341
+ "verified": {
342
+ "final_valid": true,
343
+ "valid_block_rate": 1.0,
344
+ "n_blocks": 1,
345
+ "total_denoisings": 1,
346
+ "wall_s": 1.08,
347
+ "code": "import functools\n\ndef memoize(func):\n cache = {}\n @functools.wraps(func)\n def wrapper(*args):\n if args not in cache:\n cache[args] = func(*args)\n return cache[args]\n return wrapper\n\n@memoize\ndef fib(n):\n if n < 2:\n return n\n return fib(n - 1) + fib(n - 2)"
348
+ }
349
+ },
350
+ {
351
+ "task": "a function `tokenize(source)` for a tiny language: identifiers, integers, and operators, returning a list of `(kind, value)` tuples using regex",
352
+ "vanilla": {
353
+ "final_valid": true,
354
+ "valid_block_rate": 1.0,
355
+ "n_blocks": 1,
356
+ "total_denoisings": 1,
357
+ "wall_s": 1.9,
358
+ "code": "import re\n\ndef tokenize(source):\n specification = [\n ('ID', r'[a-zA-Z_][a-zA-Z0-9_]*'),\n ('INT', r'\\d+'),\n ('OP', r'[+\\-*/=<>!|&%]+'),\n ('SKIP', r'\\s+'),\n ]\n regex = '|'.join(f'(?P<{name}>{pattern})' for name, pattern in specification)\n tokens = []\n for match in re.finditer(regex, source):\n kind = match.lastgroup\n value = match.group()\n if kind != 'SKIP':\n tokens.append((kind, value))\n return tokens"
359
+ },
360
+ "verified": {
361
+ "final_valid": true,
362
+ "valid_block_rate": 1.0,
363
+ "n_blocks": 1,
364
+ "total_denoisings": 1,
365
+ "wall_s": 1.97,
366
+ "code": "import re\n\ndef tokenize(source):\n specification = [\n ('ID', r'[a-zA-Z_][a-zA-Z0-9_]*'),\n ('INT', r'\\d+'),\n ('OP', r'[+\\-*/=<>!|&%]+'),\n ('SKIP', r'\\s+'),\n ]\n regex = '|'.join(f'(?P<{name}>{pattern})' for name, pattern in specification)\n tokens = []\n for match in re.finditer(regex, source):\n kind = match.lastgroup\n value = match.group()\n if kind != 'SKIP':\n tokens.append((kind, value))\n return tokens"
367
+ }
368
+ },
369
+ {
370
+ "task": "a `class StateMachine` configured by a transitions dict, with `fire(event)` raising on invalid transitions, and an f-string log with nested quotes",
371
+ "vanilla": {
372
+ "final_valid": true,
373
+ "valid_block_rate": 1.0,
374
+ "n_blocks": 1,
375
+ "total_denoisings": 1,
376
+ "wall_s": 1.97,
377
+ "code": "class StateMachine:\n def __init__(self, transitions, initial_state):\n self.transitions = transitions\n self.state = initial_state\n\n def fire(self, event):\n if event not in self.transitions.get(self.state, {}):\n raise ValueError(f\"Invalid event '{event}' for state '{self.state}'\")\n \n old_state = self.state\n self.state = self.transitions[self.state][event]\n print(f\"Transitioned from '{old_state}' to '{self.state}' via event '{event}'\")"
378
+ },
379
+ "verified": {
380
+ "final_valid": true,
381
+ "valid_block_rate": 1.0,
382
+ "n_blocks": 1,
383
+ "total_denoisings": 1,
384
+ "wall_s": 1.96,
385
+ "code": "class StateMachine:\n def __init__(self, transitions, initial_state):\n self.transitions = transitions\n self.state = initial_state\n\n def fire(self, event):\n if event not in self.transitions.get(self.state, {}):\n raise ValueError(f\"Invalid event '{event}' for state '{self.state}'\")\n \n old_state = self.state\n self.state = self.transitions[self.state][event]\n print(f\"Transitioned from '{old_state}' to '{self.state}' via event '{event}'\")"
386
+ }
387
+ },
388
+ {
389
+ "task": "a `topological_sort(deps: dict[str, list[str]])` using Kahn's algorithm, raising `ValueError` on a cycle",
390
+ "vanilla": {
391
+ "final_valid": true,
392
+ "valid_block_rate": 1.0,
393
+ "n_blocks": 1,
394
+ "total_denoisings": 1,
395
+ "wall_s": 1.39,
396
+ "code": "def topological_sort(deps: dict[str, list[str]]) -> list[str]:\n in_degree = {u: 0 for u in deps}\n for neighbors in deps.values():\n for v in neighbors:\n if v not in in_degree:\n in_degree[v] = 0\n in_degree[v] += 1\n\n queue = [u for u in in_degree if in_degree[u] == 0]\n sorted_list = []\n\n while queue:\n u = queue.pop(0)\n sorted_list.append(u)\n if u in deps:\n for v in deps[u]:\n in_degree[v] -= 1\n if in_degree[v] == 0:\n queue.append(v)\n\n if len(sorted_list) != len(in_degree):\n raise ValueError(\"Cycle detected in the dependency graph\")\n\n return sorted_list"
397
+ },
398
+ "verified": {
399
+ "final_valid": true,
400
+ "valid_block_rate": 1.0,
401
+ "n_blocks": 1,
402
+ "total_denoisings": 1,
403
+ "wall_s": 1.43,
404
+ "code": "def topological_sort(deps: dict[str, list[str]]) -> list[str]:\n in_degree = {u: 0 for u in deps}\n for neighbors in deps.values():\n for v in neighbors:\n if v not in in_degree:\n in_degree[v] = 0\n in_degree[v] += 1\n\n queue = [u for u in in_degree if in_degree[u] == 0]\n sorted_list = []\n\n while queue:\n u = queue.pop(0)\n sorted_list.append(u)\n if u in deps:\n for v in deps[u]:\n in_degree[v] -= 1\n if in_degree[v] == 0:\n queue.append(v)\n\n if len(sorted_list) != len(in_degree):\n raise ValueError(\"Cycle detected in the dependency graph\")\n\n return sorted_list"
405
+ }
406
+ },
407
+ {
408
+ "task": "a comprehension-heavy function `pascals_triangle(n)` returning a list of lists, plus a one-line `transpose` via zip(*m)",
409
+ "vanilla": {
410
+ "final_valid": false,
411
+ "valid_block_rate": 0.0,
412
+ "n_blocks": 1,
413
+ "total_denoisings": 1,
414
+ "wall_s": 8.65,
415
+ "code": "def pascals_triangle(n):\n return [[1] + [row[i] + row[i+1] for i in range(len(row)-1)] + [1] if row else [1] for row in (lambda t: reduce(lambda x, y: x.append([1] + [y[i] + y[i+1] for i in range(len(y)-11 + [111111111111"
416
+ },
417
+ "verified": {
418
+ "final_valid": true,
419
+ "valid_block_rate": 1.0,
420
+ "n_blocks": 1,
421
+ "total_denoisings": 2,
422
+ "wall_s": 17.12,
423
+ "code": "def pascals_triangle(n):\n return reduce(lambda acc, i: acc + [[acc[-1][j-1] if j > 0 else acc[-1][j] if j < len(acc[-1]) else 1 for j in range(i + 1)]], range(1, n), [[1]]) if n > 0 else []\n\nimport functools\nlambda m: [list(row) for row in zip(*m)]\n\nfrom functools import reduce"
424
+ }
425
+ },
426
+ {
427
+ "task": "a `class RingBuffer` with a fixed size, `append`, `__iter__`, and `__len__`, overwriting oldest entries when full",
428
+ "vanilla": {
429
+ "final_valid": true,
430
+ "valid_block_rate": 1.0,
431
+ "n_blocks": 1,
432
+ "total_denoisings": 1,
433
+ "wall_s": 1.52,
434
+ "code": "class RingBuffer:\n def __init__(self, size):\n self.size = size\n self.buffer = [None] * size\n self.count = 0\n self.head = 0\n\n def append(self, item):\n self.buffer[self.head] = item\n self.head = (self.head + 1) % self.size\n if self.count < self.size:\n self.count += 1\n\n def __iter__(self):\n start = self.head if self.count == self.size else 0\n for i in range(self.count):\n yield self.buffer[(start + i) % self.size]\n\n def __len__(self):\n return self.count"
435
+ },
436
+ "verified": {
437
+ "final_valid": true,
438
+ "valid_block_rate": 1.0,
439
+ "n_blocks": 1,
440
+ "total_denoisings": 1,
441
+ "wall_s": 1.52,
442
+ "code": "class RingBuffer:\n def __init__(self, size):\n self.size = size\n self.buffer = [None] * size\n self.count = 0\n self.head = 0\n\n def append(self, item):\n self.buffer[self.head] = item\n self.head = (self.head + 1) % self.size\n if self.count < self.size:\n self.count += 1\n\n def __iter__(self):\n start = self.head if self.count == self.size else 0\n for i in range(self.count):\n yield self.buffer[(start + i) % self.size]\n\n def __len__(self):\n return self.count"
443
+ }
444
+ }
445
+ ]
446
+ }