advent-of-code-data 2.0.2__tar.gz → 2.0.4__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.
Files changed (39) hide show
  1. advent_of_code_data-2.0.4/PKG-INFO +297 -0
  2. advent_of_code_data-2.0.4/README.md +273 -0
  3. advent_of_code_data-2.0.4/advent_of_code_data.egg-info/PKG-INFO +297 -0
  4. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/SOURCES.txt +1 -1
  5. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/__init__.py +6 -0
  6. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/get.py +20 -3
  7. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/models.py +3 -0
  8. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/pyproject.toml +3 -6
  9. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_aocd.py +11 -0
  10. advent_of_code_data-2.0.2/PKG-INFO +0 -268
  11. advent_of_code_data-2.0.2/README.rst +0 -244
  12. advent_of_code_data-2.0.2/advent_of_code_data.egg-info/PKG-INFO +0 -268
  13. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/LICENSE +0 -0
  14. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/dependency_links.txt +0 -0
  15. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/entry_points.txt +0 -0
  16. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/requires.txt +0 -0
  17. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/advent_of_code_data.egg-info/top_level.txt +0 -0
  18. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/_ipykernel.py +0 -0
  19. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/cli.py +0 -0
  20. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/cookies.py +0 -0
  21. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/examples.py +0 -0
  22. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/exceptions.py +0 -0
  23. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/post.py +0 -0
  24. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/py.typed +0 -0
  25. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/runner.py +0 -0
  26. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/types.py +0 -0
  27. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/aocd/utils.py +0 -0
  28. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/setup.cfg +0 -0
  29. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_auth.py +0 -0
  30. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_cli.py +0 -0
  31. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_cookies.py +0 -0
  32. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_date_finding.py +0 -0
  33. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_date_introspection.py +0 -0
  34. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_example_parser.py +0 -0
  35. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_get_data.py +0 -0
  36. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_models.py +0 -0
  37. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_runner.py +0 -0
  38. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_submit.py +0 -0
  39. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.4}/tests/test_utils.py +0 -0
@@ -0,0 +1,297 @@
1
+ Metadata-Version: 2.1
2
+ Name: advent-of-code-data
3
+ Version: 2.0.4
4
+ Summary: Get your puzzle data with a single import
5
+ Author-email: Wim Jeantine-Glenn <hey@wimglenn.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/wimglenn/advent-of-code-data
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Topic :: Software Development :: Libraries
12
+ Classifier: Topic :: Games/Entertainment :: Puzzle Games
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: beautifulsoup4
17
+ Requires-Dist: pebble
18
+ Requires-Dist: urllib3
19
+ Requires-Dist: tzdata; platform_system == "Windows"
20
+ Requires-Dist: aocd-example-parser>=2023.2
21
+ Provides-Extra: nb
22
+ Requires-Dist: IPython; extra == "nb"
23
+ Requires-Dist: jupyter-server; extra == "nb"
24
+
25
+ [![pypi](https://img.shields.io/pypi/v/advent-of-code-data.svg)](https://pypi.org/project/advent-of-code-data/)
26
+ [![actions](https://github.com/wimglenn/advent-of-code-data/actions/workflows/tests.yml/badge.svg)](https://github.com/wimglenn/advent-of-code-data/actions/workflows/tests.yml)
27
+ [![codecov](https://codecov.io/gh/wimglenn/advent-of-code-data/branch/main/graph/badge.svg)](https://app.codecov.io/gh/wimglenn/advent-of-code-data)
28
+ ![womm](https://cdn.rawgit.com/nikku/works-on-my-machine/v0.2.0/badge.svg)
29
+
30
+ # Advent of Code Data
31
+
32
+ Speedhackers, get your puzzle data with a single import statement:
33
+
34
+ ``` python
35
+ from aocd import data
36
+ ```
37
+
38
+ If that sounds too magical, use a simple function call to return your
39
+ data in a string:
40
+
41
+ ``` python
42
+ >>> from aocd import get_data
43
+ >>> get_data(day=24, year=2015)
44
+ '1\n2\n3\n7\n11\n13\n17\n19\n23\n31...
45
+ ```
46
+
47
+ If you'd just like to print or keep your own raw input files, there's
48
+ a script for that:
49
+
50
+ ``` bash
51
+ aocd > input.txt # saves today's data
52
+ aocd 13 2018 > day13.txt # save some other day's data
53
+ ```
54
+
55
+ Note that `aocd` will cache puzzle inputs and answers (including
56
+ incorrect guesses) clientside, to save unnecessary requests to the
57
+ server.
58
+
59
+ *New in version 2.0.0:* Get the example data (and corresponding
60
+ answers). From [2022 day 5](https://adventofcode.com/2022/day/5) there
61
+ was:
62
+
63
+ ``` bash
64
+ $ aocd 2022 5 --example
65
+ --- Day 5: Supply Stacks ---
66
+ https://adventofcode.com/2022/day/5
67
+ ------------------------------- Example data 1/1 -------------------------------
68
+ [D]
69
+ [N] [C]
70
+ [Z] [M] [P]
71
+ 1 2 3
72
+
73
+ move 1 from 2 to 1
74
+ move 3 from 1 to 3
75
+ move 2 from 2 to 1
76
+ move 1 from 1 to 2
77
+ --------------------------------------------------------------------------------
78
+ answer_a: CMZ
79
+ answer_b: MCD
80
+ --------------------------------------------------------------------------------
81
+ ```
82
+
83
+ How does scraping the examples work? Check
84
+ [aocd-example-parser](https://github.com/wimglenn/aocd-example-parser)
85
+ for the gory details.
86
+
87
+ ## Quickstart
88
+
89
+ Install with pip
90
+
91
+ ``` bash
92
+ pip install advent-of-code-data
93
+ ```
94
+
95
+ If you want to use this within a Jupyter notebook, there are some extra
96
+ deps:
97
+
98
+ ``` bash
99
+ pip install 'advent-of-code-data[nb]'
100
+ ```
101
+
102
+ **Puzzle inputs differ by user.** So export your session ID, for
103
+ example:
104
+
105
+ ``` bash
106
+ export AOC_SESSION=cafef00db01dfaceba5eba11deadbeef
107
+ ```
108
+
109
+ *Note:* Windows users should use `set` instead of `export` here.
110
+
111
+ The session ID is a cookie which is set when you login to AoC. You can
112
+ find it with your browser inspector. If you're hacking on AoC at all
113
+ you probably already know these kind of tricks, but if you need help
114
+ with that part then you can [look here](https://github.com/wimglenn/advent-of-code/issues/1).
115
+
116
+ *Note:* If you don't like the env var, you could also keep your
117
+ token(s) in files. By default the location is `~/.config/aocd/token`.
118
+ Set the `AOCD_DIR` environment variable to some existing directory if
119
+ you wish to use another location to store token(s).
120
+
121
+ *New in version 0.9.0.* There's a utility script `aocd-token` which
122
+ attempts to find session tokens from your browser's cookie storage.
123
+ This feature is experimental and requires you to additionally install
124
+ the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
125
+ are currently supported. On macOS, you may get an authentication dialog
126
+ requesting permission, since Python is attempting to read browser
127
+ storage files. This is expected, the script *is* actually scraping those
128
+ private files to access AoC session token(s).
129
+
130
+ If this utility script was able to locate your token, you can save it to
131
+ file with:
132
+
133
+ ``` bash
134
+ $ aocd-token > ~/.config/aocd/token
135
+ ```
136
+
137
+ ## Automated submission
138
+
139
+ *New in version 0.4.0.* Basic use:
140
+
141
+ ``` python
142
+ from aocd import submit
143
+ submit(my_answer, part="a", day=25, year=2017)
144
+ ```
145
+
146
+ Note that the same filename introspection of year/day also works for
147
+ automated submission. There's also introspection of the "level", i.e.
148
+ part a or part b, aocd can automatically determine if you have already
149
+ completed part a or not and submit your answer for the correct part
150
+ accordingly. In this case, just use:
151
+
152
+ ``` python
153
+ from aocd import submit
154
+ submit(my_answer)
155
+ ```
156
+
157
+ The response message from AoC will be printed in the terminal. If you
158
+ gave the right answer, then the puzzle will be refreshed in your web
159
+ browser (so you can read the instructions for the next part, for
160
+ example). **Proceed with caution!** If you submit wrong guesses, your
161
+ user **WILL** get rate-limited by Eric, so don't call submit until
162
+ you're fairly confident you have a correct answer!
163
+
164
+ *New in version 2.0.0*: Prevent submission of an answer when it is
165
+ certain the value is incorrect. For example, if the server previously
166
+ told you that your answer "1234" was too high, then aocd will remember
167
+ this info and prevent you from subsequently submitting an even higher
168
+ value such as "1300".
169
+
170
+ ## Models
171
+
172
+ *New in version 0.8.0.*
173
+
174
+ There are classes `User` and `Puzzle` found in the submodule
175
+ `aocd.models`. Input data is via regular attribute access. Example
176
+ usage:
177
+
178
+ ``` python
179
+ >>> from aocd.models import Puzzle
180
+ >>> puzzle = Puzzle(year=2017, day=20)
181
+ >>> puzzle
182
+ <Puzzle(2017, 20) at 0x107322978 - Particle Swarm>
183
+ >>> puzzle.input_data
184
+ 'p=<-1027,-979,-188>, v=<7,60,66>, a=<9,1,-7>\np=<-1846,-1539,-1147>, v=<88,145,67>, a=<6,-5,2> ...
185
+ ```
186
+
187
+ Submitting answers is also by regular attribute access. Any incorrect
188
+ answers you submitted are remembered, and aocd will prevent you from
189
+ attempting to submit the same incorrect value twice:
190
+
191
+ ``` python
192
+ >>> puzzle.answer_a = 299
193
+ That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
194
+ >>> puzzle.answer_a = 299
195
+ aocd will not submit that answer again. You've previously guessed 299 and the server responded:
196
+ That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
197
+ ```
198
+
199
+ *New in version 2.0.4:* Added convenience `from aocd import puzzle`,
200
+ to return a `Puzzle` instance bound to the auto-detected day/year/user.
201
+
202
+ Your own solutions can be executed by writing and using an
203
+ [entry-point](https://packaging.python.org/specifications/entry-points/)
204
+ into your code, registered in the group `"adventofcode.user"`. Your
205
+ entry-point should resolve to a callable, and it will be called with
206
+ three keyword arguments: `year`, `day`, and `data`. For example, [my entry-point is called "wim"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
207
+ and running against [my code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
208
+ (after `pip install advent-of-code-wim`) would be like this:
209
+
210
+ ``` python
211
+ >>> puzzle = Puzzle(year=2018, day=10)
212
+ >>> puzzle.solve_for("wim")
213
+ ('XLZAKBGZ', '10656')
214
+ ```
215
+
216
+ If you've never written a plugin before, see
217
+ <https://entrypoints.readthedocs.io/> for more info about plugin systems
218
+ based on Python entry-points.
219
+
220
+ ## Verify your code against multiple inputs
221
+
222
+ *New in version 0.8.0.*
223
+
224
+ Ever tried running your code against other people's inputs? AoC is full
225
+ of tricky edge cases. You may find that sometimes you're only getting
226
+ the right answer by luck, and your code will fail on some other dataset.
227
+ Using aocd, you can collect a few different auth tokens for each of your
228
+ accounts (github/google/reddit/twitter) and verify your answers across
229
+ multiple datasets.
230
+
231
+ To see an example of how to set up the entry-point for your code, look at
232
+ [advent-of-code-sample](https://github.com/wimglenn/advent-of-code-sample)
233
+ for some inspiration. After dumping a bunch of session tokens into
234
+ `~/.config/aocd/tokens.json` you could do something like this by running
235
+ the `aoc` console script:
236
+
237
+ ![image](https://user-images.githubusercontent.com/6615374/52138567-26e09f80-2613-11e9-8eaf-c42757bc9b86.png)
238
+
239
+ As you can see above, I actually had incorrect code for [2017 Day 20:
240
+ Particle Swarm](https://adventofcode.com/2017/day/20), but that
241
+ [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
242
+ only showed up for the google token's dataset. Whoops. Also, it looks
243
+ like my algorithm for [2017 Day 13: Packet
244
+ Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
245
+ slow. According to [AoC FAQ](https://adventofcode.com/about):
246
+
247
+ > *every problem has a solution that completes in at most 15 seconds on
248
+ > ten-year-old hardware*
249
+
250
+ By the way, the `aoc` runner will kill your code if it takes more than
251
+ 60 seconds, you can increase/decrease this by passing a command-line
252
+ option, e.g. `--timeout=120`.
253
+
254
+ *New in version 1.1.0:* Added option `--quiet` to suppress any output
255
+ from plugins so it doesn't mess up the `aoc` runner's display.
256
+
257
+ *New in version 2.0.0:* You can verify your code against the example
258
+ input data and answers, scraped from puzzle pages where available, using
259
+ `aoc --example`. This will pass the sample input data into your solver
260
+ instead of passing the full user input data.
261
+
262
+ ## How does this library work?
263
+
264
+ It will automatically get today's data at import time, if used within
265
+ the interactive interpreter. Otherwise, the date is found by
266
+ introspection of the path and file name from which `aocd` module was
267
+ imported.
268
+
269
+ This means your filenames should be something sensible. The examples
270
+ below should all parse correctly, because they have digits in the path
271
+ that are unambiguously recognisable as AoC years (2015+) or days (1-25).
272
+
273
+ ```
274
+ q03.py
275
+ xmas_problem_2016_25b_dawg.py
276
+ ~/src/aoc/2015/p8.py
277
+ ```
278
+
279
+ A filename like `problem_one.py` will not work, so don't do that. If
280
+ you don't like weird frame hacks, just use the `aocd.get_data()`
281
+ function instead and have a nice day!
282
+
283
+ ## Cache invalidation?
284
+
285
+ `aocd` saves puzzle inputs, answers, prose, and your bad guesses to
286
+ avoid hitting the AoC servers any more often than strictly necessary
287
+ (this also speeds things up). All data is persisted in plain text files
288
+ under `~/.config/aocd`. To remove any caches, you may simply delete
289
+ whatever files you want under that directory tree. If you'd prefer to
290
+ use a different path, then export an `AOCD_DIR` environment variable
291
+ with the desired location.
292
+
293
+ *New in version 1.1.0:* By default, your token files are also stored
294
+ under `~/.config/aocd`. If you want the token(s) and cached
295
+ inputs/answers to exist in separate locations, you can set the
296
+ environment variable `AOCD_CONFIG_DIR` to specify a different location
297
+ for the token(s).
@@ -0,0 +1,273 @@
1
+ [![pypi](https://img.shields.io/pypi/v/advent-of-code-data.svg)](https://pypi.org/project/advent-of-code-data/)
2
+ [![actions](https://github.com/wimglenn/advent-of-code-data/actions/workflows/tests.yml/badge.svg)](https://github.com/wimglenn/advent-of-code-data/actions/workflows/tests.yml)
3
+ [![codecov](https://codecov.io/gh/wimglenn/advent-of-code-data/branch/main/graph/badge.svg)](https://app.codecov.io/gh/wimglenn/advent-of-code-data)
4
+ ![womm](https://cdn.rawgit.com/nikku/works-on-my-machine/v0.2.0/badge.svg)
5
+
6
+ # Advent of Code Data
7
+
8
+ Speedhackers, get your puzzle data with a single import statement:
9
+
10
+ ``` python
11
+ from aocd import data
12
+ ```
13
+
14
+ If that sounds too magical, use a simple function call to return your
15
+ data in a string:
16
+
17
+ ``` python
18
+ >>> from aocd import get_data
19
+ >>> get_data(day=24, year=2015)
20
+ '1\n2\n3\n7\n11\n13\n17\n19\n23\n31...
21
+ ```
22
+
23
+ If you'd just like to print or keep your own raw input files, there's
24
+ a script for that:
25
+
26
+ ``` bash
27
+ aocd > input.txt # saves today's data
28
+ aocd 13 2018 > day13.txt # save some other day's data
29
+ ```
30
+
31
+ Note that `aocd` will cache puzzle inputs and answers (including
32
+ incorrect guesses) clientside, to save unnecessary requests to the
33
+ server.
34
+
35
+ *New in version 2.0.0:* Get the example data (and corresponding
36
+ answers). From [2022 day 5](https://adventofcode.com/2022/day/5) there
37
+ was:
38
+
39
+ ``` bash
40
+ $ aocd 2022 5 --example
41
+ --- Day 5: Supply Stacks ---
42
+ https://adventofcode.com/2022/day/5
43
+ ------------------------------- Example data 1/1 -------------------------------
44
+ [D]
45
+ [N] [C]
46
+ [Z] [M] [P]
47
+ 1 2 3
48
+
49
+ move 1 from 2 to 1
50
+ move 3 from 1 to 3
51
+ move 2 from 2 to 1
52
+ move 1 from 1 to 2
53
+ --------------------------------------------------------------------------------
54
+ answer_a: CMZ
55
+ answer_b: MCD
56
+ --------------------------------------------------------------------------------
57
+ ```
58
+
59
+ How does scraping the examples work? Check
60
+ [aocd-example-parser](https://github.com/wimglenn/aocd-example-parser)
61
+ for the gory details.
62
+
63
+ ## Quickstart
64
+
65
+ Install with pip
66
+
67
+ ``` bash
68
+ pip install advent-of-code-data
69
+ ```
70
+
71
+ If you want to use this within a Jupyter notebook, there are some extra
72
+ deps:
73
+
74
+ ``` bash
75
+ pip install 'advent-of-code-data[nb]'
76
+ ```
77
+
78
+ **Puzzle inputs differ by user.** So export your session ID, for
79
+ example:
80
+
81
+ ``` bash
82
+ export AOC_SESSION=cafef00db01dfaceba5eba11deadbeef
83
+ ```
84
+
85
+ *Note:* Windows users should use `set` instead of `export` here.
86
+
87
+ The session ID is a cookie which is set when you login to AoC. You can
88
+ find it with your browser inspector. If you're hacking on AoC at all
89
+ you probably already know these kind of tricks, but if you need help
90
+ with that part then you can [look here](https://github.com/wimglenn/advent-of-code/issues/1).
91
+
92
+ *Note:* If you don't like the env var, you could also keep your
93
+ token(s) in files. By default the location is `~/.config/aocd/token`.
94
+ Set the `AOCD_DIR` environment variable to some existing directory if
95
+ you wish to use another location to store token(s).
96
+
97
+ *New in version 0.9.0.* There's a utility script `aocd-token` which
98
+ attempts to find session tokens from your browser's cookie storage.
99
+ This feature is experimental and requires you to additionally install
100
+ the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
101
+ are currently supported. On macOS, you may get an authentication dialog
102
+ requesting permission, since Python is attempting to read browser
103
+ storage files. This is expected, the script *is* actually scraping those
104
+ private files to access AoC session token(s).
105
+
106
+ If this utility script was able to locate your token, you can save it to
107
+ file with:
108
+
109
+ ``` bash
110
+ $ aocd-token > ~/.config/aocd/token
111
+ ```
112
+
113
+ ## Automated submission
114
+
115
+ *New in version 0.4.0.* Basic use:
116
+
117
+ ``` python
118
+ from aocd import submit
119
+ submit(my_answer, part="a", day=25, year=2017)
120
+ ```
121
+
122
+ Note that the same filename introspection of year/day also works for
123
+ automated submission. There's also introspection of the "level", i.e.
124
+ part a or part b, aocd can automatically determine if you have already
125
+ completed part a or not and submit your answer for the correct part
126
+ accordingly. In this case, just use:
127
+
128
+ ``` python
129
+ from aocd import submit
130
+ submit(my_answer)
131
+ ```
132
+
133
+ The response message from AoC will be printed in the terminal. If you
134
+ gave the right answer, then the puzzle will be refreshed in your web
135
+ browser (so you can read the instructions for the next part, for
136
+ example). **Proceed with caution!** If you submit wrong guesses, your
137
+ user **WILL** get rate-limited by Eric, so don't call submit until
138
+ you're fairly confident you have a correct answer!
139
+
140
+ *New in version 2.0.0*: Prevent submission of an answer when it is
141
+ certain the value is incorrect. For example, if the server previously
142
+ told you that your answer "1234" was too high, then aocd will remember
143
+ this info and prevent you from subsequently submitting an even higher
144
+ value such as "1300".
145
+
146
+ ## Models
147
+
148
+ *New in version 0.8.0.*
149
+
150
+ There are classes `User` and `Puzzle` found in the submodule
151
+ `aocd.models`. Input data is via regular attribute access. Example
152
+ usage:
153
+
154
+ ``` python
155
+ >>> from aocd.models import Puzzle
156
+ >>> puzzle = Puzzle(year=2017, day=20)
157
+ >>> puzzle
158
+ <Puzzle(2017, 20) at 0x107322978 - Particle Swarm>
159
+ >>> puzzle.input_data
160
+ 'p=<-1027,-979,-188>, v=<7,60,66>, a=<9,1,-7>\np=<-1846,-1539,-1147>, v=<88,145,67>, a=<6,-5,2> ...
161
+ ```
162
+
163
+ Submitting answers is also by regular attribute access. Any incorrect
164
+ answers you submitted are remembered, and aocd will prevent you from
165
+ attempting to submit the same incorrect value twice:
166
+
167
+ ``` python
168
+ >>> puzzle.answer_a = 299
169
+ That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
170
+ >>> puzzle.answer_a = 299
171
+ aocd will not submit that answer again. You've previously guessed 299 and the server responded:
172
+ That's not the right answer; your answer is too high. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. (You guessed 299.) [Return to Day 20]
173
+ ```
174
+
175
+ *New in version 2.0.4:* Added convenience `from aocd import puzzle`,
176
+ to return a `Puzzle` instance bound to the auto-detected day/year/user.
177
+
178
+ Your own solutions can be executed by writing and using an
179
+ [entry-point](https://packaging.python.org/specifications/entry-points/)
180
+ into your code, registered in the group `"adventofcode.user"`. Your
181
+ entry-point should resolve to a callable, and it will be called with
182
+ three keyword arguments: `year`, `day`, and `data`. For example, [my entry-point is called "wim"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
183
+ and running against [my code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
184
+ (after `pip install advent-of-code-wim`) would be like this:
185
+
186
+ ``` python
187
+ >>> puzzle = Puzzle(year=2018, day=10)
188
+ >>> puzzle.solve_for("wim")
189
+ ('XLZAKBGZ', '10656')
190
+ ```
191
+
192
+ If you've never written a plugin before, see
193
+ <https://entrypoints.readthedocs.io/> for more info about plugin systems
194
+ based on Python entry-points.
195
+
196
+ ## Verify your code against multiple inputs
197
+
198
+ *New in version 0.8.0.*
199
+
200
+ Ever tried running your code against other people's inputs? AoC is full
201
+ of tricky edge cases. You may find that sometimes you're only getting
202
+ the right answer by luck, and your code will fail on some other dataset.
203
+ Using aocd, you can collect a few different auth tokens for each of your
204
+ accounts (github/google/reddit/twitter) and verify your answers across
205
+ multiple datasets.
206
+
207
+ To see an example of how to set up the entry-point for your code, look at
208
+ [advent-of-code-sample](https://github.com/wimglenn/advent-of-code-sample)
209
+ for some inspiration. After dumping a bunch of session tokens into
210
+ `~/.config/aocd/tokens.json` you could do something like this by running
211
+ the `aoc` console script:
212
+
213
+ ![image](https://user-images.githubusercontent.com/6615374/52138567-26e09f80-2613-11e9-8eaf-c42757bc9b86.png)
214
+
215
+ As you can see above, I actually had incorrect code for [2017 Day 20:
216
+ Particle Swarm](https://adventofcode.com/2017/day/20), but that
217
+ [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
218
+ only showed up for the google token's dataset. Whoops. Also, it looks
219
+ like my algorithm for [2017 Day 13: Packet
220
+ Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
221
+ slow. According to [AoC FAQ](https://adventofcode.com/about):
222
+
223
+ > *every problem has a solution that completes in at most 15 seconds on
224
+ > ten-year-old hardware*
225
+
226
+ By the way, the `aoc` runner will kill your code if it takes more than
227
+ 60 seconds, you can increase/decrease this by passing a command-line
228
+ option, e.g. `--timeout=120`.
229
+
230
+ *New in version 1.1.0:* Added option `--quiet` to suppress any output
231
+ from plugins so it doesn't mess up the `aoc` runner's display.
232
+
233
+ *New in version 2.0.0:* You can verify your code against the example
234
+ input data and answers, scraped from puzzle pages where available, using
235
+ `aoc --example`. This will pass the sample input data into your solver
236
+ instead of passing the full user input data.
237
+
238
+ ## How does this library work?
239
+
240
+ It will automatically get today's data at import time, if used within
241
+ the interactive interpreter. Otherwise, the date is found by
242
+ introspection of the path and file name from which `aocd` module was
243
+ imported.
244
+
245
+ This means your filenames should be something sensible. The examples
246
+ below should all parse correctly, because they have digits in the path
247
+ that are unambiguously recognisable as AoC years (2015+) or days (1-25).
248
+
249
+ ```
250
+ q03.py
251
+ xmas_problem_2016_25b_dawg.py
252
+ ~/src/aoc/2015/p8.py
253
+ ```
254
+
255
+ A filename like `problem_one.py` will not work, so don't do that. If
256
+ you don't like weird frame hacks, just use the `aocd.get_data()`
257
+ function instead and have a nice day!
258
+
259
+ ## Cache invalidation?
260
+
261
+ `aocd` saves puzzle inputs, answers, prose, and your bad guesses to
262
+ avoid hitting the AoC servers any more often than strictly necessary
263
+ (this also speeds things up). All data is persisted in plain text files
264
+ under `~/.config/aocd`. To remove any caches, you may simply delete
265
+ whatever files you want under that directory tree. If you'd prefer to
266
+ use a different path, then export an `AOCD_DIR` environment variable
267
+ with the desired location.
268
+
269
+ *New in version 1.1.0:* By default, your token files are also stored
270
+ under `~/.config/aocd`. If you want the token(s) and cached
271
+ inputs/answers to exist in separate locations, you can set the
272
+ environment variable `AOCD_CONFIG_DIR` to specify a different location
273
+ for the token(s).