aocd-example-parser 2023.1__tar.gz → 2023.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/PKG-INFO +56 -26
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/README.md +54 -24
- aocd_example_parser-2023.2/aocd_example_parser/__init__.py +1 -0
- aocd_example_parser-2023.1/aocd_example_parser/__init__.py → aocd_example_parser-2023.2/aocd_example_parser/plugins.py +5 -2
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/pyproject.toml +4 -4
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/LICENSE +0 -0
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/aocd_example_parser/examples.json +0 -0
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/aocd_example_parser/extraction.py +0 -0
- {aocd_example_parser-2023.1 → aocd_example_parser-2023.2}/aocd_example_parser/util.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aocd-example-parser
|
|
3
|
-
Version: 2023.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2023.2
|
|
4
|
+
Summary: Implementation of example parser plugins for advent-of-code-data
|
|
5
5
|
Author-email: Wim Glenn <hey@wimglenn.com>
|
|
6
6
|
Requires-Python: >=3.9
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
@@ -19,8 +19,7 @@ The annual programming challenge [Advent of Code](https://adventofcode.com/) fre
|
|
|
19
19
|
|
|
20
20
|
Although the real puzzle inputs and answers differ by user, the example data is written directly in the puzzle prose and is available to unauthenticated users too.
|
|
21
21
|
|
|
22
|
-
To illustrate what this means, the first puzzle of 2022 was [`--- Day 1: Calorie Counting ---`
|
|
23
|
-
](https://adventofcode.com/2022/day/1) and it has the following example data (54 bytes):
|
|
22
|
+
To illustrate what this means, the first puzzle of 2022 was [`--- Day 1: Calorie Counting ---`](https://adventofcode.com/2022/day/1) and it has the following example data (54 bytes):
|
|
24
23
|
|
|
25
24
|
```
|
|
26
25
|
1000
|
|
@@ -75,18 +74,22 @@ my_example_parser = "my_module:my_plugin"
|
|
|
75
74
|
|
|
76
75
|
See the [Entry points](https://peps.python.org/pep-0621/#entry-points) section in [_PEP 621 – Storing project metadata in pyproject.toml_](https://peps.python.org/pep-0621) for more information.
|
|
77
76
|
|
|
77
|
+
How to use/select a parser plugin?
|
|
78
|
+
----------------------------------
|
|
79
|
+
|
|
78
80
|
When an example parser package is correctly installed alongside [advent-of-code-data >= 2.0.0](https://github.com/wimglenn/advent-of-code-data), it will show up as a choice in `aoce --help`:
|
|
79
81
|
|
|
80
82
|
```bash
|
|
81
83
|
$ aoce --help
|
|
82
|
-
usage: aoce [-h] [-
|
|
84
|
+
usage: aoce [-h] [-e {reference,simple}] [-y 2015+ [2015+ ...]] [-v]
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
options:
|
|
85
87
|
-h, --help show this help message and exit
|
|
86
|
-
-
|
|
87
|
-
plugin to use for example extraction testing (default:
|
|
88
|
-
-y
|
|
89
|
-
|
|
88
|
+
-e {reference,simple}, --example-parser {reference,simple}
|
|
89
|
+
plugin to use for example extraction testing (default: reference)
|
|
90
|
+
-y 2015+ [2015+ ...], --years 2015+ [2015+ ...]
|
|
91
|
+
years to run the parser against (can specify multiple)
|
|
92
|
+
-v, --verbose increased logging (-v INFO, -vv DEBUG)
|
|
90
93
|
```
|
|
91
94
|
|
|
92
95
|
And it should be selectable for use/verification with
|
|
@@ -95,6 +98,33 @@ And it should be selectable for use/verification with
|
|
|
95
98
|
$ aoce --plugin=my_example_parser
|
|
96
99
|
```
|
|
97
100
|
|
|
101
|
+
To print the actual results produced by a parser against a single puzzle, you may use `aocd --example-parser`. To demonstrate using the results for [`--- Day 1: Calorie Counting ---`](https://adventofcode.com/2022/day/1) again:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
$ aocd 2022 1 --example-parser=reference
|
|
105
|
+
--- Day 1: Calorie Counting ---
|
|
106
|
+
https://adventofcode.com/2022/day/1
|
|
107
|
+
------------------------------- Example data 1/1 -------------------------------
|
|
108
|
+
1000
|
|
109
|
+
2000
|
|
110
|
+
3000
|
|
111
|
+
|
|
112
|
+
4000
|
|
113
|
+
|
|
114
|
+
5000
|
|
115
|
+
6000
|
|
116
|
+
|
|
117
|
+
7000
|
|
118
|
+
8000
|
|
119
|
+
9000
|
|
120
|
+
|
|
121
|
+
10000
|
|
122
|
+
--------------------------------------------------------------------------------
|
|
123
|
+
answer_a: 24000
|
|
124
|
+
answer_b: 45000
|
|
125
|
+
--------------------------------------------------------------------------------
|
|
126
|
+
```
|
|
127
|
+
|
|
98
128
|
|
|
99
129
|
Why a plugin? Wouldn't it be simpler to write a parser in aocd directly?
|
|
100
130
|
------------------------------------------------------------------------
|
|
@@ -106,10 +136,10 @@ There are so many creative and smart people hacking on AoC that I'm sure several
|
|
|
106
136
|
The default implementation from `aocd` fails more than 40% of the time, so you don't have a very high bar to beat.
|
|
107
137
|
If someone comes up with a better-performing parser than "_take the first pre as input data, take answers from the last codeblocks in each article_", I will make their implementation the new default in a future version of `aocd`.
|
|
108
138
|
|
|
109
|
-
If you're considering writing an example parser, it's not advisable to
|
|
110
|
-
Some of the puzzles have [many examples](https://adventofcode.com/
|
|
139
|
+
If you're considering writing an example parser, it's not advisable to strive for 100% success rate, that will be super-difficult if not _impossible_.
|
|
140
|
+
Some of the puzzles have [many examples](https://adventofcode.com/2020/day/15), some are [really tricky to parse](https://adventofcode.com/2018/day/15), and some offer [no example at all](https://adventofcode.com/2018/day/21).
|
|
111
141
|
But difficulty aside, the main reason is that you needn't "overfit" to previous puzzles.
|
|
112
|
-
This is because `advent-of-code-data` always intends to return correct example data _for past puzzles_ by hardcoding the code-block locations.
|
|
142
|
+
This is because `advent-of-code-data` always intends to return correct example data _for past puzzles_ by hardcoding the [relevant code-block locations](https://github.com/wimglenn/aocd-example-parser/blob/main/aocd_example_parser/examples.json). The unwritten rule is that `aocd-example-parser` versions 2023.* will return verified results for Advent of Code <= 2022, and unverified best-effort result for 2023+.
|
|
113
143
|
|
|
114
144
|
**The only thing that matters for a parser plugin is how well it can perform for a never-before seen puzzle**.
|
|
115
145
|
That is, the goal is to maximize the _probability_ that your parser will somehow find the right result at the instant a new puzzle unlocks.
|
|
@@ -124,29 +154,29 @@ The final line that `aoce` script prints out is a rough percentage the parser go
|
|
|
124
154
|
|
|
125
155
|
```bash
|
|
126
156
|
$ for YEAR in {2015..2022};
|
|
127
|
-
do echo -n "$YEAR " && aoce -
|
|
157
|
+
do echo -n "$YEAR " && aoce -e simple -y $YEAR | tail -1;
|
|
128
158
|
done
|
|
129
|
-
2015 plugin '
|
|
130
|
-
2016 plugin '
|
|
131
|
-
2017 plugin '
|
|
132
|
-
2018 plugin '
|
|
133
|
-
2019 plugin '
|
|
134
|
-
2020 plugin '
|
|
135
|
-
2021 plugin '
|
|
136
|
-
2022 plugin '
|
|
159
|
+
2015 plugin 'simple' scored 78/336 (23.2%)
|
|
160
|
+
2016 plugin 'simple' scored 53/159 (33.3%)
|
|
161
|
+
2017 plugin 'simple' scored 85/221 (38.5%)
|
|
162
|
+
2018 plugin 'simple' scored 69/212 (32.5%)
|
|
163
|
+
2019 plugin 'simple' scored 43/204 (21.1%)
|
|
164
|
+
2020 plugin 'simple' scored 67/183 (36.6%)
|
|
165
|
+
2021 plugin 'simple' scored 82/152 (53.9%)
|
|
166
|
+
2022 plugin 'simple' scored 71/120 (59.2%)
|
|
137
167
|
```
|
|
138
168
|
|
|
139
169
|
Averaging across all years, we're currently right about a third of the time:
|
|
140
170
|
|
|
141
171
|
```bash
|
|
142
|
-
$ aoce -
|
|
143
|
-
plugin '
|
|
172
|
+
$ aoce -e simple | tail -1
|
|
173
|
+
plugin 'simple' scored 548/1587 (34.5%)
|
|
144
174
|
```
|
|
145
175
|
|
|
146
176
|
Of course, the "reference" plugin is always correct _for historical puzzles_.
|
|
147
177
|
|
|
148
178
|
```bash
|
|
149
|
-
$ aoce -
|
|
150
|
-
plugin '
|
|
179
|
+
$ aoce -e reference | tail -1
|
|
180
|
+
plugin 'reference' scored 1587/1587 (100.0%)
|
|
151
181
|
```
|
|
152
182
|
|
|
@@ -5,8 +5,7 @@ The annual programming challenge [Advent of Code](https://adventofcode.com/) fre
|
|
|
5
5
|
|
|
6
6
|
Although the real puzzle inputs and answers differ by user, the example data is written directly in the puzzle prose and is available to unauthenticated users too.
|
|
7
7
|
|
|
8
|
-
To illustrate what this means, the first puzzle of 2022 was [`--- Day 1: Calorie Counting ---`
|
|
9
|
-
](https://adventofcode.com/2022/day/1) and it has the following example data (54 bytes):
|
|
8
|
+
To illustrate what this means, the first puzzle of 2022 was [`--- Day 1: Calorie Counting ---`](https://adventofcode.com/2022/day/1) and it has the following example data (54 bytes):
|
|
10
9
|
|
|
11
10
|
```
|
|
12
11
|
1000
|
|
@@ -61,18 +60,22 @@ my_example_parser = "my_module:my_plugin"
|
|
|
61
60
|
|
|
62
61
|
See the [Entry points](https://peps.python.org/pep-0621/#entry-points) section in [_PEP 621 – Storing project metadata in pyproject.toml_](https://peps.python.org/pep-0621) for more information.
|
|
63
62
|
|
|
63
|
+
How to use/select a parser plugin?
|
|
64
|
+
----------------------------------
|
|
65
|
+
|
|
64
66
|
When an example parser package is correctly installed alongside [advent-of-code-data >= 2.0.0](https://github.com/wimglenn/advent-of-code-data), it will show up as a choice in `aoce --help`:
|
|
65
67
|
|
|
66
68
|
```bash
|
|
67
69
|
$ aoce --help
|
|
68
|
-
usage: aoce [-h] [-
|
|
70
|
+
usage: aoce [-h] [-e {reference,simple}] [-y 2015+ [2015+ ...]] [-v]
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
options:
|
|
71
73
|
-h, --help show this help message and exit
|
|
72
|
-
-
|
|
73
|
-
plugin to use for example extraction testing (default:
|
|
74
|
-
-y
|
|
75
|
-
|
|
74
|
+
-e {reference,simple}, --example-parser {reference,simple}
|
|
75
|
+
plugin to use for example extraction testing (default: reference)
|
|
76
|
+
-y 2015+ [2015+ ...], --years 2015+ [2015+ ...]
|
|
77
|
+
years to run the parser against (can specify multiple)
|
|
78
|
+
-v, --verbose increased logging (-v INFO, -vv DEBUG)
|
|
76
79
|
```
|
|
77
80
|
|
|
78
81
|
And it should be selectable for use/verification with
|
|
@@ -81,6 +84,33 @@ And it should be selectable for use/verification with
|
|
|
81
84
|
$ aoce --plugin=my_example_parser
|
|
82
85
|
```
|
|
83
86
|
|
|
87
|
+
To print the actual results produced by a parser against a single puzzle, you may use `aocd --example-parser`. To demonstrate using the results for [`--- Day 1: Calorie Counting ---`](https://adventofcode.com/2022/day/1) again:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
$ aocd 2022 1 --example-parser=reference
|
|
91
|
+
--- Day 1: Calorie Counting ---
|
|
92
|
+
https://adventofcode.com/2022/day/1
|
|
93
|
+
------------------------------- Example data 1/1 -------------------------------
|
|
94
|
+
1000
|
|
95
|
+
2000
|
|
96
|
+
3000
|
|
97
|
+
|
|
98
|
+
4000
|
|
99
|
+
|
|
100
|
+
5000
|
|
101
|
+
6000
|
|
102
|
+
|
|
103
|
+
7000
|
|
104
|
+
8000
|
|
105
|
+
9000
|
|
106
|
+
|
|
107
|
+
10000
|
|
108
|
+
--------------------------------------------------------------------------------
|
|
109
|
+
answer_a: 24000
|
|
110
|
+
answer_b: 45000
|
|
111
|
+
--------------------------------------------------------------------------------
|
|
112
|
+
```
|
|
113
|
+
|
|
84
114
|
|
|
85
115
|
Why a plugin? Wouldn't it be simpler to write a parser in aocd directly?
|
|
86
116
|
------------------------------------------------------------------------
|
|
@@ -92,10 +122,10 @@ There are so many creative and smart people hacking on AoC that I'm sure several
|
|
|
92
122
|
The default implementation from `aocd` fails more than 40% of the time, so you don't have a very high bar to beat.
|
|
93
123
|
If someone comes up with a better-performing parser than "_take the first pre as input data, take answers from the last codeblocks in each article_", I will make their implementation the new default in a future version of `aocd`.
|
|
94
124
|
|
|
95
|
-
If you're considering writing an example parser, it's not advisable to
|
|
96
|
-
Some of the puzzles have [many examples](https://adventofcode.com/
|
|
125
|
+
If you're considering writing an example parser, it's not advisable to strive for 100% success rate, that will be super-difficult if not _impossible_.
|
|
126
|
+
Some of the puzzles have [many examples](https://adventofcode.com/2020/day/15), some are [really tricky to parse](https://adventofcode.com/2018/day/15), and some offer [no example at all](https://adventofcode.com/2018/day/21).
|
|
97
127
|
But difficulty aside, the main reason is that you needn't "overfit" to previous puzzles.
|
|
98
|
-
This is because `advent-of-code-data` always intends to return correct example data _for past puzzles_ by hardcoding the code-block locations.
|
|
128
|
+
This is because `advent-of-code-data` always intends to return correct example data _for past puzzles_ by hardcoding the [relevant code-block locations](https://github.com/wimglenn/aocd-example-parser/blob/main/aocd_example_parser/examples.json). The unwritten rule is that `aocd-example-parser` versions 2023.* will return verified results for Advent of Code <= 2022, and unverified best-effort result for 2023+.
|
|
99
129
|
|
|
100
130
|
**The only thing that matters for a parser plugin is how well it can perform for a never-before seen puzzle**.
|
|
101
131
|
That is, the goal is to maximize the _probability_ that your parser will somehow find the right result at the instant a new puzzle unlocks.
|
|
@@ -110,28 +140,28 @@ The final line that `aoce` script prints out is a rough percentage the parser go
|
|
|
110
140
|
|
|
111
141
|
```bash
|
|
112
142
|
$ for YEAR in {2015..2022};
|
|
113
|
-
do echo -n "$YEAR " && aoce -
|
|
143
|
+
do echo -n "$YEAR " && aoce -e simple -y $YEAR | tail -1;
|
|
114
144
|
done
|
|
115
|
-
2015 plugin '
|
|
116
|
-
2016 plugin '
|
|
117
|
-
2017 plugin '
|
|
118
|
-
2018 plugin '
|
|
119
|
-
2019 plugin '
|
|
120
|
-
2020 plugin '
|
|
121
|
-
2021 plugin '
|
|
122
|
-
2022 plugin '
|
|
145
|
+
2015 plugin 'simple' scored 78/336 (23.2%)
|
|
146
|
+
2016 plugin 'simple' scored 53/159 (33.3%)
|
|
147
|
+
2017 plugin 'simple' scored 85/221 (38.5%)
|
|
148
|
+
2018 plugin 'simple' scored 69/212 (32.5%)
|
|
149
|
+
2019 plugin 'simple' scored 43/204 (21.1%)
|
|
150
|
+
2020 plugin 'simple' scored 67/183 (36.6%)
|
|
151
|
+
2021 plugin 'simple' scored 82/152 (53.9%)
|
|
152
|
+
2022 plugin 'simple' scored 71/120 (59.2%)
|
|
123
153
|
```
|
|
124
154
|
|
|
125
155
|
Averaging across all years, we're currently right about a third of the time:
|
|
126
156
|
|
|
127
157
|
```bash
|
|
128
|
-
$ aoce -
|
|
129
|
-
plugin '
|
|
158
|
+
$ aoce -e simple | tail -1
|
|
159
|
+
plugin 'simple' scored 548/1587 (34.5%)
|
|
130
160
|
```
|
|
131
161
|
|
|
132
162
|
Of course, the "reference" plugin is always correct _for historical puzzles_.
|
|
133
163
|
|
|
134
164
|
```bash
|
|
135
|
-
$ aoce -
|
|
136
|
-
plugin '
|
|
165
|
+
$ aoce -e reference | tail -1
|
|
166
|
+
plugin 'reference' scored 1587/1587 (100.0%)
|
|
137
167
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .plugins import *
|
|
@@ -5,8 +5,11 @@ from .extraction import extract_examples
|
|
|
5
5
|
from .util import real_datas_unused
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
__all__ = ["simple", "reference"]
|
|
9
|
+
|
|
10
|
+
|
|
8
11
|
@real_datas_unused
|
|
9
|
-
def
|
|
12
|
+
def simple(page: Page, datas: list[str]) -> list[Example]:
|
|
10
13
|
"""
|
|
11
14
|
Example parser implementation which always uses the aocd default locators.
|
|
12
15
|
These are currently:
|
|
@@ -27,7 +30,7 @@ def plugin(page: Page, datas: list[str]) -> list[Example]:
|
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
@real_datas_unused
|
|
30
|
-
def
|
|
33
|
+
def reference(page: Page, datas: list[str]) -> list[Example]:
|
|
31
34
|
"""
|
|
32
35
|
Example parser implementation which always uses the pre-calculated locators.
|
|
33
36
|
This implementation will always return correct results for puzzles which are
|
|
@@ -4,8 +4,8 @@ build-backend = "flit_core.buildapi"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aocd-example-parser"
|
|
7
|
-
version = "2023.
|
|
8
|
-
description = "
|
|
7
|
+
version = "2023.2"
|
|
8
|
+
description = "Implementation of example parser plugins for advent-of-code-data"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
11
11
|
classifiers = [
|
|
@@ -27,5 +27,5 @@ file = "LICENSE"
|
|
|
27
27
|
Home = "https://github.com/wimglenn/aocd-example-parser"
|
|
28
28
|
|
|
29
29
|
[project.entry-points."adventofcode.examples"]
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
simple = "aocd_example_parser:simple"
|
|
31
|
+
reference = "aocd_example_parser:reference"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|