Skip to content

Commit 6aee78c

Browse files
committed
Added Hackathon_puzzles.ipynb!
Removed @register command using Problem.__subclasses__() from all templates Changed the debug format to subclass Problem.Debug Sped up generation so that it does not re-test solutions that were tested in the current json Added a handful of puzzles Added aka.ms link to the notebook on Binder
1 parent 0c08611 commit 6aee78c

36 files changed

+102600
-43805
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pip-wheel-metadata/
2424
share/python-wheels/
2525
*.egg-info/
2626
.installed.cfg
27+
.idea
2728
*.egg
2829
MANIFEST
2930

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ an AI's programming proficiency. We hope this dataset with **grow rapidly**, and
55
terms of problem difficult, domain,
66
and algorithmic tools needed to solve the problems. Please [contribute](../../wiki/How-to-add-a-puzzle)!
77

8+
To learn more about how well AI systems such as GPT-3 can solve these problems, read our paper:
9+
10+
[Programming Puzzles](https://arxiv.org/abs/2106.05784). Tal Schuster, Ashwin Kalyan, Oleksandr Polozov,
11+
Adam Tauman Kalai.
12+
```
13+
@misc{schuster2021programming,
14+
title={Programming Puzzles},
15+
author={Tal Schuster and Ashwin Kalyan and Oleksandr Polozov and Adam Tauman Kalai},
16+
year={2021},
17+
eprint={2106.05784},
18+
archivePrefix={arXiv},
19+
}
20+
```
21+
22+
823

924
## What is a python programming puzzle?
1025

@@ -58,6 +73,42 @@ and [math problems](https://en.wikipedia.org/wiki/List_of_unsolved_problems_in_m
5873
* The website [codeforces.com](https://codeforces.com), a popular website for programming competition problems
5974
* Olympiad problems from the [International Collegiate Programming Contest](https://icpc.global) and [International Mathematical Olympiad](https://en.wikipedia.org/wiki/International_Mathematical_Olympiad).
6075

76+
77+
## Notebooks
78+
79+
The [notebooks](/notebooks) subdirectory has some relevant notebooks. [Demo.ipynb](/notebooks/Demo.ipynb)
80+
has the 30 problems completed by our users in a user study. [Try the notebook at Binder](https://aka.ms/python_puzzles)
81+
and see how your programming compares to the AI baselines!
82+
83+
### Hackathon
84+
During a Microsoft hackathon July 27-29, 2020, several people completed 30 user
85+
[study puzzles](/problems/README.md#study). We also had tons of fun making the puzzles in
86+
[Hackathon_puzzles.ipynb](/notebooks/Hackathon_puzzles.ipynb). These are of a somewhat
87+
different flavor as they are more often `hacks` like
88+
```python
89+
def f(x):
90+
return x > x
91+
```
92+
where the type of `x` is clearly non-standard. The creators of these puzzles include github users:
93+
[Adam Tauman Kalai](akalai),
94+
[Alec Helbling](helblazer811),
95+
[Alexander Vorobev](OnFireDolphin),
96+
[Alexander Wei](aw31),
97+
[Alexey Romanov](jgc128),
98+
[Keith Battaochi](kbattocchi),
99+
[Maggie Hei](heimengqi),
100+
[Misha Khodak](mkhodak),
101+
[Monil Mehta](monilm2),
102+
[Philip Rosenfield](philrosenfield),
103+
[Qida Ma](JerryMa90),
104+
[Raj Bhargava](rajbhargava),
105+
[Rishi Jaiswal](nextquanta),
106+
[Saikiran Mullaguri](sm947),
107+
[Tal Schuster](TalSchuster), and
108+
[Varsha Srinivasan](varsha2197).
109+
You can try out the notebook at (link to be added).
110+
111+
61112
## Highlights
62113
* Numerous trivial puzzles like reversing a list, useful for learning to program
63114
* Classic puzzles like:

make_dataset.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import problems
66
import utils
77
import templates # This loads all the problem templates
8+
import inspect
89

910
TARGET_NUM_PER_PROBLEM = 1000
1011

@@ -27,15 +28,24 @@
2728

2829
def main(args):
2930
start_time = time.perf_counter()
30-
templates = fnmatch.filter(problems.problem_registry.keys(), args.templates)
31-
utils.info(f"Generating from templates: {templates}")
31+
if problems.Problem.Debug.subclass_descendents(): # if there are debug problems, don't make the dataset
32+
problems.Problem.debug_problems()
33+
print("Didn't make dataset because there are `Problem.Debug` problems, remove the `.Debug` to proceed.")
34+
return
35+
36+
all_probs = problems.Problem.subclass_descendents()
37+
38+
probs_by_template = utils.inv_dict({p: p.__module__.split(".")[-1] for p in all_probs})
39+
40+
used_templates = fnmatch.filter(probs_by_template, args.templates)
41+
utils.info(f"Generating from templates: {used_templates}")
3242
problem_sets = []
33-
for name in templates: # order determined by import order in templates/__init__.py
34-
entry = problems.problem_registry[name]
35-
ps = problems.ProblemSet(entry["name"], entry["summary"])
36-
for cls in entry["classes"]:
43+
for name in used_templates: # order determined by import order in templates/__init__.py
44+
probs = probs_by_template[name]
45+
ps = problems.ProblemSet(name, inspect.getmodule(probs[0]).__doc__)
46+
for cls in probs:
3747
problem = cls()
38-
problem.build(args.target_num_per_problem)
48+
problem.build(args.target_num_per_problem, ps.get_already_tested())
3949
ps.add(problem)
4050
ps.save()
4151
problem_sets.append(ps)

0 commit comments

Comments
 (0)