advent-of-code-data 2.0.2__tar.gz → 2.0.3__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.3/PKG-INFO +298 -0
  2. advent_of_code_data-2.0.3/README.md +274 -0
  3. advent_of_code_data-2.0.3/advent_of_code_data.egg-info/PKG-INFO +298 -0
  4. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/advent_of_code_data.egg-info/SOURCES.txt +1 -1
  5. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/models.py +3 -0
  6. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/pyproject.toml +3 -6
  7. advent_of_code_data-2.0.2/PKG-INFO +0 -268
  8. advent_of_code_data-2.0.2/README.rst +0 -244
  9. advent_of_code_data-2.0.2/advent_of_code_data.egg-info/PKG-INFO +0 -268
  10. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/LICENSE +0 -0
  11. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/advent_of_code_data.egg-info/dependency_links.txt +0 -0
  12. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/advent_of_code_data.egg-info/entry_points.txt +0 -0
  13. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/advent_of_code_data.egg-info/requires.txt +0 -0
  14. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/advent_of_code_data.egg-info/top_level.txt +0 -0
  15. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/__init__.py +0 -0
  16. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/_ipykernel.py +0 -0
  17. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/cli.py +0 -0
  18. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/cookies.py +0 -0
  19. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/examples.py +0 -0
  20. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/exceptions.py +0 -0
  21. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/get.py +0 -0
  22. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/post.py +0 -0
  23. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/py.typed +0 -0
  24. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/runner.py +0 -0
  25. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/types.py +0 -0
  26. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/aocd/utils.py +0 -0
  27. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/setup.cfg +0 -0
  28. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_aocd.py +0 -0
  29. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_auth.py +0 -0
  30. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_cli.py +0 -0
  31. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_cookies.py +0 -0
  32. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_date_finding.py +0 -0
  33. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_date_introspection.py +0 -0
  34. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_example_parser.py +0 -0
  35. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_get_data.py +0 -0
  36. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_models.py +0 -0
  37. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_runner.py +0 -0
  38. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_submit.py +0 -0
  39. {advent_of_code_data-2.0.2 → advent_of_code_data-2.0.3}/tests/test_utils.py +0 -0
@@ -0,0 +1,298 @@
1
+ Metadata-Version: 2.1
2
+ Name: advent-of-code-data
3
+ Version: 2.0.3
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
115
+ here](https://github.com/wimglenn/advent-of-code/issues/1).
116
+
117
+ *Note:* If you don\'t like the env var, you could also keep your
118
+ token(s) in files. By default the location is `~/.config/aocd/token`.
119
+ Set the `AOCD_DIR` environment variable to some existing directory if
120
+ you wish to use another location to store token(s).
121
+
122
+ *New in version 0.9.0.* There\'s a utility script `aocd-token` which
123
+ attempts to find session tokens from your browser\'s cookie storage.
124
+ This feature is experimental and requires you to additionally install
125
+ the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
126
+ are currently supported. On macOS, you may get an authentication dialog
127
+ requesting permission, since Python is attempting to read browser
128
+ storage files. This is expected, the script *is* actually scraping those
129
+ private files to access AoC session token(s).
130
+
131
+ If this utility script was able to locate your token, you can save it to
132
+ file with:
133
+
134
+ ``` bash
135
+ $ aocd-token > ~/.config/aocd/token
136
+ ```
137
+
138
+ ## Automated submission
139
+
140
+ *New in version 0.4.0.* Basic use:
141
+
142
+ ``` python
143
+ from aocd import submit
144
+ submit(my_answer, part="a", day=25, year=2017)
145
+ ```
146
+
147
+ Note that the same filename introspection of year/day also works for
148
+ automated submission. There\'s also introspection of the \"level\", i.e.
149
+ part a or part b, aocd can automatically determine if you have already
150
+ completed part a or not and submit your answer for the correct part
151
+ accordingly. In this case, just use:
152
+
153
+ ``` python
154
+ from aocd import submit
155
+ submit(my_answer)
156
+ ```
157
+
158
+ The response message from AoC will be printed in the terminal. If you
159
+ gave the right answer, then the puzzle will be refreshed in your web
160
+ browser (so you can read the instructions for the next part, for
161
+ example). **Proceed with caution!** If you submit wrong guesses, your
162
+ user **WILL** get rate-limited by Eric, so don\'t call submit until
163
+ you\'re fairly confident you have a correct answer!
164
+
165
+ *New in version 2.0.0*: Prevent submission of an answer when it is
166
+ certain the value is incorrect. For example, if the server previously
167
+ told you that your answer \"1234\" was too high, then aocd will remember
168
+ this info and prevent you from subsequently submitting an even higher
169
+ value such as \"1300\".
170
+
171
+ ## Models
172
+
173
+ *New in version 0.8.0.*
174
+
175
+ There are classes `User` and `Puzzle` found in the submodule
176
+ `aocd.models`. Input data is via regular attribute access. Example
177
+ usage:
178
+
179
+ ``` python
180
+ >>> from aocd.models import Puzzle
181
+ >>> puzzle = Puzzle(year=2017, day=20)
182
+ >>> puzzle
183
+ <Puzzle(2017, 20) at 0x107322978 - Particle Swarm>
184
+ >>> puzzle.input_data
185
+ 'p=<-1027,-979,-188>, v=<7,60,66>, a=<9,1,-7>\np=<-1846,-1539,-1147>, v=<88,145,67>, a=<6,-5,2> ...
186
+ ```
187
+
188
+ Submitting answers is also by regular attribute access. Any incorrect
189
+ answers you submitted are remembered, and aocd will prevent you from
190
+ attempting to submit the same incorrect value twice:
191
+
192
+ ``` python
193
+ >>> puzzle.answer_a = 299
194
+ 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]
195
+ >>> puzzle.answer_a = 299
196
+ aocd will not submit that answer again. You've previously guessed 299 and the server responded:
197
+ 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]
198
+ ```
199
+
200
+ Your own solutions can be executed by writing and using an
201
+ [entry-point](https://packaging.python.org/specifications/entry-points/)
202
+ into your code, registered in the group `"adventofcode.user"`. Your
203
+ entry-point should resolve to a callable, and it will be called with
204
+ three keyword arguments: `year`, `day`, and `data`. For example, [my
205
+ entry-point is called
206
+ \"wim\"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
207
+ and running against [my
208
+ code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
209
+ (after `pip install advent-of-code-wim`) would be like this:
210
+
211
+ ``` python
212
+ >>> puzzle = Puzzle(year=2018, day=10)
213
+ >>> puzzle.solve_for("wim")
214
+ ('XLZAKBGZ', '10656')
215
+ ```
216
+
217
+ If you\'ve never written a plugin before, see
218
+ <https://entrypoints.readthedocs.io/> for more info about plugin systems
219
+ based on Python entry-points.
220
+
221
+ ## Verify your code against multiple inputs
222
+
223
+ *New in version 0.8.0.*
224
+
225
+ Ever tried running your code against other people\'s inputs? AoC is full
226
+ of tricky edge cases. You may find that sometimes you\'re only getting
227
+ the right answer by luck, and your code will fail on some other dataset.
228
+ Using aocd, you can collect a few different auth tokens for each of your
229
+ accounts (github/google/reddit/twitter) and verify your answers across
230
+ multiple datasets.
231
+
232
+ To see an example of how to set up the entry-point for your code, look at
233
+ [advent-of-code-sample](https://github.com/wimglenn/advent-of-code-sample)
234
+ for some inspiration. After dumping a bunch of session tokens into
235
+ `~/.config/aocd/tokens.json` you could do something like this by running
236
+ the `aoc` console script:
237
+
238
+ ![image](https://user-images.githubusercontent.com/6615374/52138567-26e09f80-2613-11e9-8eaf-c42757bc9b86.png)
239
+
240
+ As you can see above, I actually had incorrect code for [2017 Day 20:
241
+ Particle Swarm](https://adventofcode.com/2017/day/20), but that
242
+ [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
243
+ only showed up for the google token\'s dataset. Whoops. Also, it looks
244
+ like my algorithm for [2017 Day 13: Packet
245
+ Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
246
+ slow. According to [AoC FAQ](https://adventofcode.com/about):
247
+
248
+ > *every problem has a solution that completes in at most 15 seconds on
249
+ > ten-year-old hardware*
250
+
251
+ By the way, the `aoc` runner will kill your code if it takes more than
252
+ 60 seconds, you can increase/decrease this by passing a command-line
253
+ option, e.g. `--timeout=120`.
254
+
255
+ *New in version 1.1.0:* Added option `--quiet` to suppress any output
256
+ from plugins so it doesn\'t mess up the `aoc` runner\'s display.
257
+
258
+ *New in version 2.0.0:* You can verify your code against the example
259
+ input data and answers, scraped from puzzle pages where available, using
260
+ `aoc --example`. This will pass the sample input data into your solver
261
+ instead of passing the full user input data.
262
+
263
+ ## How does this library work?
264
+
265
+ It will automatically get today\'s data at import time, if used within
266
+ the interactive interpreter. Otherwise, the date is found by
267
+ introspection of the path and file name from which `aocd` module was
268
+ imported.
269
+
270
+ This means your filenames should be something sensible. The examples
271
+ below should all parse correctly, because they have digits in the path
272
+ that are unambiguously recognisable as AoC years (2015+) or days (1-25).
273
+
274
+ ```
275
+ q03.py
276
+ xmas_problem_2016_25b_dawg.py
277
+ ~/src/aoc/2015/p8.py
278
+ ```
279
+
280
+ A filename like `problem_one.py` will not work, so don\'t do that. If
281
+ you don\'t like weird frame hacks, just use the `aocd.get_data()`
282
+ function instead and have a nice day!
283
+
284
+ ## Cache invalidation?
285
+
286
+ `aocd` saves puzzle inputs, answers, prose, and your bad guesses to
287
+ avoid hitting the AoC servers any more often than strictly necessary
288
+ (this also speeds things up). All data is persisted in plain text files
289
+ under `~/.config/aocd`. To remove any caches, you may simply delete
290
+ whatever files you want under that directory tree. If you\'d prefer to
291
+ use a different path, then export an `AOCD_DIR` environment variable
292
+ with the desired location.
293
+
294
+ *New in version 1.1.0:* By default, your token files are also stored
295
+ under `~/.config/aocd`. If you want the token(s) and cached
296
+ inputs/answers to exist in separate locations, you can set the
297
+ environment variable `AOCD_CONFIG_DIR` to specify a different location
298
+ for the token(s).
@@ -0,0 +1,274 @@
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
91
+ here](https://github.com/wimglenn/advent-of-code/issues/1).
92
+
93
+ *Note:* If you don\'t like the env var, you could also keep your
94
+ token(s) in files. By default the location is `~/.config/aocd/token`.
95
+ Set the `AOCD_DIR` environment variable to some existing directory if
96
+ you wish to use another location to store token(s).
97
+
98
+ *New in version 0.9.0.* There\'s a utility script `aocd-token` which
99
+ attempts to find session tokens from your browser\'s cookie storage.
100
+ This feature is experimental and requires you to additionally install
101
+ the package `browser-cookie3`. Only Chrome, Firefox, and Edge browsers
102
+ are currently supported. On macOS, you may get an authentication dialog
103
+ requesting permission, since Python is attempting to read browser
104
+ storage files. This is expected, the script *is* actually scraping those
105
+ private files to access AoC session token(s).
106
+
107
+ If this utility script was able to locate your token, you can save it to
108
+ file with:
109
+
110
+ ``` bash
111
+ $ aocd-token > ~/.config/aocd/token
112
+ ```
113
+
114
+ ## Automated submission
115
+
116
+ *New in version 0.4.0.* Basic use:
117
+
118
+ ``` python
119
+ from aocd import submit
120
+ submit(my_answer, part="a", day=25, year=2017)
121
+ ```
122
+
123
+ Note that the same filename introspection of year/day also works for
124
+ automated submission. There\'s also introspection of the \"level\", i.e.
125
+ part a or part b, aocd can automatically determine if you have already
126
+ completed part a or not and submit your answer for the correct part
127
+ accordingly. In this case, just use:
128
+
129
+ ``` python
130
+ from aocd import submit
131
+ submit(my_answer)
132
+ ```
133
+
134
+ The response message from AoC will be printed in the terminal. If you
135
+ gave the right answer, then the puzzle will be refreshed in your web
136
+ browser (so you can read the instructions for the next part, for
137
+ example). **Proceed with caution!** If you submit wrong guesses, your
138
+ user **WILL** get rate-limited by Eric, so don\'t call submit until
139
+ you\'re fairly confident you have a correct answer!
140
+
141
+ *New in version 2.0.0*: Prevent submission of an answer when it is
142
+ certain the value is incorrect. For example, if the server previously
143
+ told you that your answer \"1234\" was too high, then aocd will remember
144
+ this info and prevent you from subsequently submitting an even higher
145
+ value such as \"1300\".
146
+
147
+ ## Models
148
+
149
+ *New in version 0.8.0.*
150
+
151
+ There are classes `User` and `Puzzle` found in the submodule
152
+ `aocd.models`. Input data is via regular attribute access. Example
153
+ usage:
154
+
155
+ ``` python
156
+ >>> from aocd.models import Puzzle
157
+ >>> puzzle = Puzzle(year=2017, day=20)
158
+ >>> puzzle
159
+ <Puzzle(2017, 20) at 0x107322978 - Particle Swarm>
160
+ >>> puzzle.input_data
161
+ 'p=<-1027,-979,-188>, v=<7,60,66>, a=<9,1,-7>\np=<-1846,-1539,-1147>, v=<88,145,67>, a=<6,-5,2> ...
162
+ ```
163
+
164
+ Submitting answers is also by regular attribute access. Any incorrect
165
+ answers you submitted are remembered, and aocd will prevent you from
166
+ attempting to submit the same incorrect value twice:
167
+
168
+ ``` python
169
+ >>> puzzle.answer_a = 299
170
+ 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]
171
+ >>> puzzle.answer_a = 299
172
+ aocd will not submit that answer again. You've previously guessed 299 and the server responded:
173
+ 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]
174
+ ```
175
+
176
+ Your own solutions can be executed by writing and using an
177
+ [entry-point](https://packaging.python.org/specifications/entry-points/)
178
+ into your code, registered in the group `"adventofcode.user"`. Your
179
+ entry-point should resolve to a callable, and it will be called with
180
+ three keyword arguments: `year`, `day`, and `data`. For example, [my
181
+ entry-point is called
182
+ \"wim\"](https://github.com/wimglenn/advent-of-code-wim/blob/d033366c16fba50e413f2fa7df32e8a0eac9542f/setup.py#L36)
183
+ and running against [my
184
+ code](https://github.com/wimglenn/advent-of-code-wim/blob/main/aoc_wim/__init__.py)
185
+ (after `pip install advent-of-code-wim`) would be like this:
186
+
187
+ ``` python
188
+ >>> puzzle = Puzzle(year=2018, day=10)
189
+ >>> puzzle.solve_for("wim")
190
+ ('XLZAKBGZ', '10656')
191
+ ```
192
+
193
+ If you\'ve never written a plugin before, see
194
+ <https://entrypoints.readthedocs.io/> for more info about plugin systems
195
+ based on Python entry-points.
196
+
197
+ ## Verify your code against multiple inputs
198
+
199
+ *New in version 0.8.0.*
200
+
201
+ Ever tried running your code against other people\'s inputs? AoC is full
202
+ of tricky edge cases. You may find that sometimes you\'re only getting
203
+ the right answer by luck, and your code will fail on some other dataset.
204
+ Using aocd, you can collect a few different auth tokens for each of your
205
+ accounts (github/google/reddit/twitter) and verify your answers across
206
+ multiple datasets.
207
+
208
+ To see an example of how to set up the entry-point for your code, look at
209
+ [advent-of-code-sample](https://github.com/wimglenn/advent-of-code-sample)
210
+ for some inspiration. After dumping a bunch of session tokens into
211
+ `~/.config/aocd/tokens.json` you could do something like this by running
212
+ the `aoc` console script:
213
+
214
+ ![image](https://user-images.githubusercontent.com/6615374/52138567-26e09f80-2613-11e9-8eaf-c42757bc9b86.png)
215
+
216
+ As you can see above, I actually had incorrect code for [2017 Day 20:
217
+ Particle Swarm](https://adventofcode.com/2017/day/20), but that
218
+ [bug](https://github.com/wimglenn/advent-of-code-wim/commit/31e454270001c6d06b46014fe5dafd03e29507b8)
219
+ only showed up for the google token\'s dataset. Whoops. Also, it looks
220
+ like my algorithm for [2017 Day 13: Packet
221
+ Scanners](https://adventofcode.com/2017/day/13) was kinda garbage. Too
222
+ slow. According to [AoC FAQ](https://adventofcode.com/about):
223
+
224
+ > *every problem has a solution that completes in at most 15 seconds on
225
+ > ten-year-old hardware*
226
+
227
+ By the way, the `aoc` runner will kill your code if it takes more than
228
+ 60 seconds, you can increase/decrease this by passing a command-line
229
+ option, e.g. `--timeout=120`.
230
+
231
+ *New in version 1.1.0:* Added option `--quiet` to suppress any output
232
+ from plugins so it doesn\'t mess up the `aoc` runner\'s display.
233
+
234
+ *New in version 2.0.0:* You can verify your code against the example
235
+ input data and answers, scraped from puzzle pages where available, using
236
+ `aoc --example`. This will pass the sample input data into your solver
237
+ instead of passing the full user input data.
238
+
239
+ ## How does this library work?
240
+
241
+ It will automatically get today\'s data at import time, if used within
242
+ the interactive interpreter. Otherwise, the date is found by
243
+ introspection of the path and file name from which `aocd` module was
244
+ imported.
245
+
246
+ This means your filenames should be something sensible. The examples
247
+ below should all parse correctly, because they have digits in the path
248
+ that are unambiguously recognisable as AoC years (2015+) or days (1-25).
249
+
250
+ ```
251
+ q03.py
252
+ xmas_problem_2016_25b_dawg.py
253
+ ~/src/aoc/2015/p8.py
254
+ ```
255
+
256
+ A filename like `problem_one.py` will not work, so don\'t do that. If
257
+ you don\'t like weird frame hacks, just use the `aocd.get_data()`
258
+ function instead and have a nice day!
259
+
260
+ ## Cache invalidation?
261
+
262
+ `aocd` saves puzzle inputs, answers, prose, and your bad guesses to
263
+ avoid hitting the AoC servers any more often than strictly necessary
264
+ (this also speeds things up). All data is persisted in plain text files
265
+ under `~/.config/aocd`. To remove any caches, you may simply delete
266
+ whatever files you want under that directory tree. If you\'d prefer to
267
+ use a different path, then export an `AOCD_DIR` environment variable
268
+ with the desired location.
269
+
270
+ *New in version 1.1.0:* By default, your token files are also stored
271
+ under `~/.config/aocd`. If you want the token(s) and cached
272
+ inputs/answers to exist in separate locations, you can set the
273
+ environment variable `AOCD_CONFIG_DIR` to specify a different location
274
+ for the token(s).