aocd-example-parser 2025.12.11__tar.gz → 2026.12.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-2025.12.11 → aocd_example_parser-2026.12.2}/PKG-INFO +29 -16
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/README.md +27 -14
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/examples.json +42 -0
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/pyproject.toml +2 -2
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/LICENSE +0 -0
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/__init__.py +0 -0
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/extraction.py +0 -0
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/plugins.py +0 -0
- {aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aocd-example-parser
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2026.12.2
|
|
4
4
|
Summary: Implementation of example parser plugins for advent-of-code-data
|
|
5
5
|
Author-email: Wim Jeantine-Glenn <hey@wimglenn.com>
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
11
11
|
Classifier: Topic :: Software Development :: Libraries
|
|
12
12
|
Classifier: Topic :: Games/Entertainment :: Puzzle Games
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Project-URL:
|
|
14
|
+
Project-URL: Homepage, https://github.com/wimglenn/aocd-example-parser
|
|
15
15
|
|
|
16
16
|
Advent-of-Code-Data Example Parser
|
|
17
17
|
==================================
|
|
@@ -39,7 +39,9 @@ To illustrate what this means, the first puzzle of 2022 was [`--- Day 1: Calorie
|
|
|
39
39
|
10000
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
The correct answers corresponding to this sample data were `24000` for part a, and `45000` for part b.
|
|
42
|
+
The correct answers corresponding to this sample data were `24000` for part a, and `45000` for part b.
|
|
43
|
+
The example data text was found in the first `<pre>` tag, and the answers were found in the last `<code>` blocks from each of the two `<article>` sections in the puzzle page HTML.
|
|
44
|
+
Note that the first half of the puzzle must be solved before the second `<article>` tag shows up, so the second article is not visible to unauthenticated users.
|
|
43
45
|
|
|
44
46
|
In 2022, this same pattern of example data locations in the HTML was repeated for four more days, consecutively, before varying on [`--- Day 6: Tuning Trouble ---`](https://adventofcode.com/2022/day/6).
|
|
45
47
|
|
|
@@ -49,7 +51,8 @@ What is this package?
|
|
|
49
51
|
|
|
50
52
|
This package provides an implementation of an [aocd example parser](https://github.com/wimglenn/advent-of-code-data/blob/main/aocd/examples.py) plugin, which attempts to parse the sample data and corresponding answers automatically from the puzzle prose.
|
|
51
53
|
|
|
52
|
-
An aocd example parser plugin is an [entry-point](https://packaging.python.org/en/latest/specifications/entry-points/) in the `"adventofcode.examples"` group.
|
|
54
|
+
An aocd example parser plugin is an [entry-point](https://packaging.python.org/en/latest/specifications/entry-points/) in the `"adventofcode.examples"` group.
|
|
55
|
+
It must be a callable accepting two arguments, like this:
|
|
53
56
|
|
|
54
57
|
```python
|
|
55
58
|
from aocd.examples import Example
|
|
@@ -65,7 +68,8 @@ def my_plugin(page: Page, datas: list[str]) -> list[Example]:
|
|
|
65
68
|
return result
|
|
66
69
|
```
|
|
67
70
|
|
|
68
|
-
This callable must return a list of `Example` instances.
|
|
71
|
+
This callable must return a list of `Example` instances.
|
|
72
|
+
If no examples can be parsed, you should return an empty list `[]`, rather than `None`.
|
|
69
73
|
|
|
70
74
|
Any package providing an example parser should register an entry point in the `"adventofcode.examples"` group within the package metadata, by adding something like this in your `pyproject.toml` file:
|
|
71
75
|
```toml
|
|
@@ -99,7 +103,8 @@ And it should be selectable for use/verification with
|
|
|
99
103
|
$ aoce --example-parser=my_example_parser
|
|
100
104
|
```
|
|
101
105
|
|
|
102
|
-
To print the actual results produced by a parser against a single puzzle, you may use `aocd --example-parser`.
|
|
106
|
+
To print the actual results produced by a parser against a single puzzle, you may use `aocd --example-parser`.
|
|
107
|
+
To demonstrate using the results for [`--- Day 1: Calorie Counting ---`](https://adventofcode.com/2022/day/1) again:
|
|
103
108
|
|
|
104
109
|
```bash
|
|
105
110
|
$ aocd 2022 1 --example-parser=reference
|
|
@@ -131,15 +136,20 @@ Why a plugin? Wouldn't it be simpler to write a parser in aocd directly?
|
|
|
131
136
|
------------------------------------------------------------------------
|
|
132
137
|
|
|
133
138
|
I've created this package, and the corresponding tester `aoce` in `advent-of-code-data`, to open it up to the community to try and come up with a better parser.
|
|
134
|
-
This package exemplifies the interface that a parser should work with, so to speak, and `aocd` uses this plugin for [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food).
|
|
139
|
+
This package exemplifies the interface that a parser should work with, so to speak, and `aocd` uses this plugin for [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food).
|
|
140
|
+
As an added benefit, it means the example parsing can be frequently updated to ensure correct results are returned for previous puzzles, without requiring a new release of `aocd` itself.
|
|
135
141
|
|
|
136
142
|
There are so many creative and smart people hacking on AoC that I'm sure someone can up with something much better than I was able to!
|
|
137
|
-
The default implementation from `aocd` fails more than 40% of the time, so you don't have a very high bar to beat.
|
|
143
|
+
The default implementation from `aocd` fails more than 40% of the time, so you don't have a very high bar to beat.
|
|
144
|
+
Anything that scores better than `aoce -e simple` is an improvement.
|
|
145
|
+
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`.
|
|
138
146
|
|
|
139
147
|
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
148
|
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).
|
|
141
149
|
But difficulty aside, the main reason is that you needn't "overfit" to previous puzzles.
|
|
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).
|
|
150
|
+
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).
|
|
151
|
+
The package uses a [CalVer](https://calver.org/)-ish scheme where the version string indicates up until which date the results have been manually verified.
|
|
152
|
+
So, `aocd-example-parser` version 2023.12.17 can be expected to return verified results for all Advent of Code puzzles <= 2023/12/17, and an unverified best-effort result for 2023/12/18+.
|
|
143
153
|
|
|
144
154
|
**The only thing that matters for a parser plugin is how well it can perform for a never-before seen puzzle**.
|
|
145
155
|
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.
|
|
@@ -153,30 +163,33 @@ The locations got a lot more consistent in recent years, so it has performed bet
|
|
|
153
163
|
The final line that `aoce` script prints out is a rough percentage the parser got right.
|
|
154
164
|
|
|
155
165
|
```bash
|
|
156
|
-
$ for YEAR in {2015..
|
|
166
|
+
$ for YEAR in {2015..2025};
|
|
157
167
|
do echo -n "$YEAR " && aoce -e simple -y $YEAR | tail -1;
|
|
158
168
|
done
|
|
159
|
-
2015 plugin 'simple' scored
|
|
169
|
+
2015 plugin 'simple' scored 72/315 (22.9%)
|
|
160
170
|
2016 plugin 'simple' scored 53/159 (33.3%)
|
|
161
|
-
2017 plugin 'simple' scored
|
|
171
|
+
2017 plugin 'simple' scored 86/230 (37.4%)
|
|
162
172
|
2018 plugin 'simple' scored 69/212 (32.5%)
|
|
163
|
-
2019 plugin 'simple' scored
|
|
173
|
+
2019 plugin 'simple' scored 47/216 (21.8%)
|
|
164
174
|
2020 plugin 'simple' scored 67/183 (36.6%)
|
|
165
175
|
2021 plugin 'simple' scored 82/152 (53.9%)
|
|
166
176
|
2022 plugin 'simple' scored 71/120 (59.2%)
|
|
177
|
+
2023 plugin 'simple' scored 89/147 (60.5%)
|
|
178
|
+
2024 plugin 'simple' scored 70/138 (50.7%)
|
|
179
|
+
2025 plugin 'simple' scored 41/50 (82.0%)
|
|
167
180
|
```
|
|
168
181
|
|
|
169
|
-
Averaging across all years, we're currently right about
|
|
182
|
+
Averaging across all years, we're currently right about 40% of the time:
|
|
170
183
|
|
|
171
184
|
```bash
|
|
172
185
|
$ aoce -e simple | tail -1
|
|
173
|
-
plugin 'simple' scored
|
|
186
|
+
plugin 'simple' scored 747/1922 (38.9%)
|
|
174
187
|
```
|
|
175
188
|
|
|
176
189
|
Of course, the "reference" plugin is always correct _for historical puzzles_.
|
|
177
190
|
|
|
178
191
|
```bash
|
|
179
192
|
$ aoce -e reference | tail -1
|
|
180
|
-
plugin 'reference' scored
|
|
193
|
+
plugin 'reference' scored 1922/1922 (100.0%)
|
|
181
194
|
```
|
|
182
195
|
|
|
@@ -24,7 +24,9 @@ To illustrate what this means, the first puzzle of 2022 was [`--- Day 1: Calorie
|
|
|
24
24
|
10000
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
The correct answers corresponding to this sample data were `24000` for part a, and `45000` for part b.
|
|
27
|
+
The correct answers corresponding to this sample data were `24000` for part a, and `45000` for part b.
|
|
28
|
+
The example data text was found in the first `<pre>` tag, and the answers were found in the last `<code>` blocks from each of the two `<article>` sections in the puzzle page HTML.
|
|
29
|
+
Note that the first half of the puzzle must be solved before the second `<article>` tag shows up, so the second article is not visible to unauthenticated users.
|
|
28
30
|
|
|
29
31
|
In 2022, this same pattern of example data locations in the HTML was repeated for four more days, consecutively, before varying on [`--- Day 6: Tuning Trouble ---`](https://adventofcode.com/2022/day/6).
|
|
30
32
|
|
|
@@ -34,7 +36,8 @@ What is this package?
|
|
|
34
36
|
|
|
35
37
|
This package provides an implementation of an [aocd example parser](https://github.com/wimglenn/advent-of-code-data/blob/main/aocd/examples.py) plugin, which attempts to parse the sample data and corresponding answers automatically from the puzzle prose.
|
|
36
38
|
|
|
37
|
-
An aocd example parser plugin is an [entry-point](https://packaging.python.org/en/latest/specifications/entry-points/) in the `"adventofcode.examples"` group.
|
|
39
|
+
An aocd example parser plugin is an [entry-point](https://packaging.python.org/en/latest/specifications/entry-points/) in the `"adventofcode.examples"` group.
|
|
40
|
+
It must be a callable accepting two arguments, like this:
|
|
38
41
|
|
|
39
42
|
```python
|
|
40
43
|
from aocd.examples import Example
|
|
@@ -50,7 +53,8 @@ def my_plugin(page: Page, datas: list[str]) -> list[Example]:
|
|
|
50
53
|
return result
|
|
51
54
|
```
|
|
52
55
|
|
|
53
|
-
This callable must return a list of `Example` instances.
|
|
56
|
+
This callable must return a list of `Example` instances.
|
|
57
|
+
If no examples can be parsed, you should return an empty list `[]`, rather than `None`.
|
|
54
58
|
|
|
55
59
|
Any package providing an example parser should register an entry point in the `"adventofcode.examples"` group within the package metadata, by adding something like this in your `pyproject.toml` file:
|
|
56
60
|
```toml
|
|
@@ -84,7 +88,8 @@ And it should be selectable for use/verification with
|
|
|
84
88
|
$ aoce --example-parser=my_example_parser
|
|
85
89
|
```
|
|
86
90
|
|
|
87
|
-
To print the actual results produced by a parser against a single puzzle, you may use `aocd --example-parser`.
|
|
91
|
+
To print the actual results produced by a parser against a single puzzle, you may use `aocd --example-parser`.
|
|
92
|
+
To demonstrate using the results for [`--- Day 1: Calorie Counting ---`](https://adventofcode.com/2022/day/1) again:
|
|
88
93
|
|
|
89
94
|
```bash
|
|
90
95
|
$ aocd 2022 1 --example-parser=reference
|
|
@@ -116,15 +121,20 @@ Why a plugin? Wouldn't it be simpler to write a parser in aocd directly?
|
|
|
116
121
|
------------------------------------------------------------------------
|
|
117
122
|
|
|
118
123
|
I've created this package, and the corresponding tester `aoce` in `advent-of-code-data`, to open it up to the community to try and come up with a better parser.
|
|
119
|
-
This package exemplifies the interface that a parser should work with, so to speak, and `aocd` uses this plugin for [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food).
|
|
124
|
+
This package exemplifies the interface that a parser should work with, so to speak, and `aocd` uses this plugin for [dogfooding](https://en.wikipedia.org/wiki/Eating_your_own_dog_food).
|
|
125
|
+
As an added benefit, it means the example parsing can be frequently updated to ensure correct results are returned for previous puzzles, without requiring a new release of `aocd` itself.
|
|
120
126
|
|
|
121
127
|
There are so many creative and smart people hacking on AoC that I'm sure someone can up with something much better than I was able to!
|
|
122
|
-
The default implementation from `aocd` fails more than 40% of the time, so you don't have a very high bar to beat.
|
|
128
|
+
The default implementation from `aocd` fails more than 40% of the time, so you don't have a very high bar to beat.
|
|
129
|
+
Anything that scores better than `aoce -e simple` is an improvement.
|
|
130
|
+
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`.
|
|
123
131
|
|
|
124
132
|
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_.
|
|
125
133
|
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).
|
|
126
134
|
But difficulty aside, the main reason is that you needn't "overfit" to previous puzzles.
|
|
127
|
-
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).
|
|
135
|
+
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).
|
|
136
|
+
The package uses a [CalVer](https://calver.org/)-ish scheme where the version string indicates up until which date the results have been manually verified.
|
|
137
|
+
So, `aocd-example-parser` version 2023.12.17 can be expected to return verified results for all Advent of Code puzzles <= 2023/12/17, and an unverified best-effort result for 2023/12/18+.
|
|
128
138
|
|
|
129
139
|
**The only thing that matters for a parser plugin is how well it can perform for a never-before seen puzzle**.
|
|
130
140
|
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.
|
|
@@ -138,29 +148,32 @@ The locations got a lot more consistent in recent years, so it has performed bet
|
|
|
138
148
|
The final line that `aoce` script prints out is a rough percentage the parser got right.
|
|
139
149
|
|
|
140
150
|
```bash
|
|
141
|
-
$ for YEAR in {2015..
|
|
151
|
+
$ for YEAR in {2015..2025};
|
|
142
152
|
do echo -n "$YEAR " && aoce -e simple -y $YEAR | tail -1;
|
|
143
153
|
done
|
|
144
|
-
2015 plugin 'simple' scored
|
|
154
|
+
2015 plugin 'simple' scored 72/315 (22.9%)
|
|
145
155
|
2016 plugin 'simple' scored 53/159 (33.3%)
|
|
146
|
-
2017 plugin 'simple' scored
|
|
156
|
+
2017 plugin 'simple' scored 86/230 (37.4%)
|
|
147
157
|
2018 plugin 'simple' scored 69/212 (32.5%)
|
|
148
|
-
2019 plugin 'simple' scored
|
|
158
|
+
2019 plugin 'simple' scored 47/216 (21.8%)
|
|
149
159
|
2020 plugin 'simple' scored 67/183 (36.6%)
|
|
150
160
|
2021 plugin 'simple' scored 82/152 (53.9%)
|
|
151
161
|
2022 plugin 'simple' scored 71/120 (59.2%)
|
|
162
|
+
2023 plugin 'simple' scored 89/147 (60.5%)
|
|
163
|
+
2024 plugin 'simple' scored 70/138 (50.7%)
|
|
164
|
+
2025 plugin 'simple' scored 41/50 (82.0%)
|
|
152
165
|
```
|
|
153
166
|
|
|
154
|
-
Averaging across all years, we're currently right about
|
|
167
|
+
Averaging across all years, we're currently right about 40% of the time:
|
|
155
168
|
|
|
156
169
|
```bash
|
|
157
170
|
$ aoce -e simple | tail -1
|
|
158
|
-
plugin 'simple' scored
|
|
171
|
+
plugin 'simple' scored 747/1922 (38.9%)
|
|
159
172
|
```
|
|
160
173
|
|
|
161
174
|
Of course, the "reference" plugin is always correct _for historical puzzles_.
|
|
162
175
|
|
|
163
176
|
```bash
|
|
164
177
|
$ aoce -e reference | tail -1
|
|
165
|
-
plugin 'reference' scored
|
|
178
|
+
plugin 'reference' scored 1922/1922 (100.0%)
|
|
166
179
|
```
|
{aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/examples.json
RENAMED
|
@@ -2772,5 +2772,47 @@
|
|
|
2772
2772
|
"answer_a": "None",
|
|
2773
2773
|
"answer_b": "b_code[-9]"
|
|
2774
2774
|
}
|
|
2775
|
+
],
|
|
2776
|
+
"2026/02": [
|
|
2777
|
+
{
|
|
2778
|
+
"input_data": "a_code[12]",
|
|
2779
|
+
"answer_a": "a_code[-7]",
|
|
2780
|
+
"answer_b": "None"
|
|
2781
|
+
},
|
|
2782
|
+
{
|
|
2783
|
+
"input_data": "a_li[0].codes[0]",
|
|
2784
|
+
"answer_a": "a_li[0].codes[1]",
|
|
2785
|
+
"answer_b": "None"
|
|
2786
|
+
},
|
|
2787
|
+
{
|
|
2788
|
+
"input_data": "a_li[1].codes[0]",
|
|
2789
|
+
"answer_a": "a_li[1].codes[1]",
|
|
2790
|
+
"answer_b": "None"
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
"input_data": "a_li[2].codes[0]",
|
|
2794
|
+
"answer_a": "a_li[2].codes[1]",
|
|
2795
|
+
"answer_b": "None"
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
"input_data": "b_code[3]",
|
|
2799
|
+
"answer_a": "None",
|
|
2800
|
+
"answer_b": "b_code[-8]"
|
|
2801
|
+
},
|
|
2802
|
+
{
|
|
2803
|
+
"input_data": "b_li[-3].codes[0]",
|
|
2804
|
+
"answer_a": "None",
|
|
2805
|
+
"answer_b": "b_li[-3].codes[-1]"
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
"input_data": "b_li[-2].codes[0]",
|
|
2809
|
+
"answer_a": "None",
|
|
2810
|
+
"answer_b": "b_li[-2].codes[-1]"
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
"input_data": "b_li[-1].codes[0]",
|
|
2814
|
+
"answer_a": "None",
|
|
2815
|
+
"answer_b": "b_li[-1].codes[-1]"
|
|
2816
|
+
}
|
|
2775
2817
|
]
|
|
2776
2818
|
}
|
|
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aocd-example-parser"
|
|
7
|
-
version = "
|
|
7
|
+
version = "2026.12.2"
|
|
8
8
|
description = "Implementation of example parser plugins for advent-of-code-data"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
readme = "README.md"
|
|
@@ -21,7 +21,7 @@ name = "Wim Jeantine-Glenn"
|
|
|
21
21
|
email = "hey@wimglenn.com"
|
|
22
22
|
|
|
23
23
|
[project.urls]
|
|
24
|
-
|
|
24
|
+
Homepage = "https://github.com/wimglenn/aocd-example-parser"
|
|
25
25
|
|
|
26
26
|
[project.entry-points."adventofcode.examples"]
|
|
27
27
|
simple = "aocd_example_parser:simple"
|
|
File without changes
|
{aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/__init__.py
RENAMED
|
File without changes
|
{aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/extraction.py
RENAMED
|
File without changes
|
{aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/plugins.py
RENAMED
|
File without changes
|
{aocd_example_parser-2025.12.11 → aocd_example_parser-2026.12.2}/aocd_example_parser/util.py
RENAMED
|
File without changes
|