Package: advent-of-code-sample
advent-of-code-sample:Provides a working example plugin structure for using theaocrunner script provided byadvent-of-code-data.Theaocrunner allows you to easily verify yourAdvent of Codesolutions against multiple datasets, or verify other user's code against your own dataset.$cat~/.config/aocd/tokens.json# create this file with some auth tokens{"github":"53616c7465645f5f0775...","google":"53616c7465645f5f7238...","reddit":"53616c7465645f5ff7c8...","twitter":"53616c7465645f5fa524..."}$pipinstall~/src/advent-of-code-sample# install the directory which contains your setup.py file...
$pipinstall-qadvent-of-code-wim# can also install some other user's code if you want..?...
$aoc--years2015--days3411# run it!0.25s2015/3-PerfectlySphericalHousesinaVacuumwim/github✔parta:2565✔partb:26390.11s2015/3-PerfectlySphericalHousesinaVacuumwim/google✔parta:2592✔partb:23600.12s2015/3-PerfectlySphericalHousesinaVacuumwim/reddit✔parta:2592✔partb:23600.12s2015/3-PerfectlySphericalHousesinaVacuumwim/twitter✔parta:2565✔partb:26390.12s2015/3-PerfectlySphericalHousesinaVacuummyusername/github✖parta:1234(expected:2565)✖partb:5678(expected:2639)0.12s2015/3-PerfectlySphericalHousesinaVacuummyusername/google✖parta:1234(expected:2592)✖partb:5678(expected:2360)0.11s2015/3-PerfectlySphericalHousesinaVacuummyusername/reddit✖parta:1234(expected:2592)✖partb:5678(expected:2360)0.11s2015/3-PerfectlySphericalHousesinaVacuummyusername/twitter✖parta:1234(expected:2565)✖partb:5678(expected:2639)9.04s2015/4-TheIdealStockingStufferwim/github✔parta:254575✔partb:103873625.43s2015/4-TheIdealStockingStufferwim/google✔parta:117946✔partb:393803812.20s2015/4-TheIdealStockingStufferwim/reddit✔parta:254575✔partb:103873647.67s2015/4-TheIdealStockingStufferwim/twitter✔parta:282749✔partb:99626240.12s2015/4-TheIdealStockingStuffermyusername/github✖parta:1234(expected:254575)✖partb:5678(expected:1038736)0.12s2015/4-TheIdealStockingStuffermyusername/google✖parta:1234(expected:117946)✖partb:5678(expected:3938038)0.12s2015/4-TheIdealStockingStuffermyusername/reddit✖parta:1234(expected:254575)✖partb:5678(expected:1038736)0.12s2015/4-TheIdealStockingStuffermyusername/twitter✖parta:1234(expected:282749)✖partb:5678(expected:9962624)6.17s2015/11-CorporatePolicywim/github✔parta:vzbxxyzz✔partb:vzcaabcc6.26s2015/11-CorporatePolicywim/google✔parta:cqjxxyzz✔partb:cqkaabcc4.69s2015/11-CorporatePolicywim/reddit✔parta:hxbxxyzz✔partb:hxcaabcc5.75s2015/11-CorporatePolicywim/twitter✔parta:hxbxxyzz✔partb:hxcaabcc0.11s2015/11-CorporatePolicymyusername/github✖parta:1234(expected:vzbxxyzz)✖partb:5678(expected:vzcaabcc)0.12s2015/11-CorporatePolicymyusername/google✖parta:1234(expected:cqjxxyzz)✖partb:5678(expected:cqkaabcc)0.11s2015/11-CorporatePolicymyusername/reddit✖parta:1234(expected:hxbxxyzz)✖partb:5678(expected:hxcaabcc)0.12s2015/11-CorporatePolicymyusername/twitter✖parta:1234(expected:hxbxxyzz)✖partb:5678(expected:hxcaabcc)How to hook into your code:Theaocrunner uses setuptools'dynamic discovery of services and pluginsfeature to locate and run your code.
Define your plugin's entry point insetup.py. The group name to use is "adventofcode.user":# setup.pyfromsetuptoolsimportsetupsetup(...entry_points={"adventofcode.user":["myusername = mypackage:mysolve"]},)Changemypackageto whatever package or module name is used to import your stuff.
The namemysolveshould resolve to a callable in your package's namespace which accepts three named argumentsyear,day,data(any order ok) and returns two values, e.g.:defmysolve(year,day,data):...returnpart_a_answer,part_b_answerInside the entry-point you can do whatever you need in order to delegate to your code. For example, write out data to a scratch file then run a script, or import a function and just pass in the data directly as an argument.
The only requirement is that this entry-point should return a tuple of two values, with the answers for that day's puzzle, the rest is up to you.
You could fork this repo and edit it, or just write your own plugin manually.