Skip to content

Commit c2e2a60

Browse files
committed
Added codex puzzles, Fixed rare masking problem in ml_bow_bigram.py, Removed the asserts from problems/README.md
1 parent 29f071e commit c2e2a60

File tree

7 files changed

+11582
-3497
lines changed

7 files changed

+11582
-3497
lines changed

problems.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,13 @@ def debug(self, target_num_instances=10000):
763763
Problem.Debug = DebugProblem
764764

765765

766+
def remove_type_assertion(src: str):
767+
lines = src.split("\n")
768+
assert lines[1].strip().startswith("assert type")
769+
lines.pop(1)
770+
return "\n".join(lines)
771+
772+
766773
def get_src_spec(f: Callable):
767774
try:
768775
src = inspect.getsource(f)
@@ -818,7 +825,12 @@ def get_func_name(src):
818825
def save_readme(problem_sets, filename=os.path.join(PATH, "README.md")):
819826
top = """# Python Programming Puzzles: dataset summary
820827
This document summarizes the dataset stored in .json files.
821-
Each .json file contains a number of related problems with one or more puzzles each.
828+
Each .json file contains a number of related problems with one or more puzzles each. (Each puzzle in the json
829+
files contains an assert statement on its first line ensuring that the input is of the correct type---these
830+
assertions have been removed below for readability.) The only import required for puzzles is:
831+
```from typing import List, Set, Dict```
832+
833+
822834
823835
## Files:
824836
@@ -828,6 +840,8 @@ def save_readme(problem_sets, filename=os.path.join(PATH, "README.md")):
828840
829841
"""
830842

843+
844+
831845
table = ""
832846
content = ""
833847
tot_probs = 0
@@ -847,7 +861,7 @@ def save_readme(problem_sets, filename=os.path.join(PATH, "README.md")):
847861
for i, problem in enumerate(ps.problems):
848862
section += f"### {problem.name}\n({link} {i + 1:,}/{n:,})\n\n"
849863
section += f"**Description:**\n{problem.desc}\n\n"
850-
section += f"**Problem:**\n\n```python\n{problem.instances[0].src}\n```\n"
864+
section += f"**Problem:**\n\n```python\n{remove_type_assertion(problem.instances[0].src)}\n```\n"
851865
if len(problem.instances[0].sol_srcs) > 0:
852866
section += "<details><summary><strong>Reveal solution(s):</strong></summary>\n\n"
853867
for sol in problem.instances[0].sol_srcs:
@@ -862,6 +876,7 @@ def save_readme(problem_sets, filename=os.path.join(PATH, "README.md")):
862876

863877
table += f"\nTotal ({tot_probs:,} problems, {tot_instances:,} instances)\n"
864878

879+
865880
content = top.format(table) + content
866881

867882
with open(filename, "w", encoding='utf8') as f:

0 commit comments

Comments
 (0)