{"id":43242215,"url":"https://github.com/nekitdev/aoc-core","last_synced_at":"2026-02-01T11:38:54.637Z","repository":{"id":210527956,"uuid":"726235999","full_name":"nekitdev/aoc-core","owner":"nekitdev","description":"Advent of Code in Python.","archived":false,"fork":false,"pushed_at":"2024-04-23T12:58:47.000Z","size":755,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-22T06:39:35.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://nekitdev.github.io/aoc-core","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nekitdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["nekitdev"],"custom":"https://nekit.dev/funding"}},"created_at":"2023-12-01T20:42:10.000Z","updated_at":"2024-04-23T12:57:29.000Z","dependencies_parsed_at":"2024-02-08T17:05:38.221Z","dependency_job_id":null,"html_url":"https://github.com/nekitdev/aoc-core","commit_stats":null,"previous_names":["nekitdev/aoc.py","nekitdev/aoc-core"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nekitdev/aoc-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitdev%2Faoc-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitdev%2Faoc-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitdev%2Faoc-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitdev%2Faoc-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nekitdev","download_url":"https://codeload.github.com/nekitdev/aoc-core/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitdev%2Faoc-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28977334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T11:31:13.034Z","status":"ssl_error","status_checked_at":"2026-02-01T11:30:25.558Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-01T11:38:54.477Z","updated_at":"2026-02-01T11:38:54.629Z","avatar_url":"https://github.com/nekitdev.png","language":"Python","funding_links":["https://github.com/sponsors/nekitdev","https://nekit.dev/funding"],"categories":[],"sub_categories":[],"readme":"# `aoc-core`\n\n[![License][License Badge]][License]\n[![Version][Version Badge]][Package]\n[![Downloads][Downloads Badge]][Package]\n[![Discord][Discord Badge]][Discord]\n\n[![Documentation][Documentation Badge]][Documentation]\n[![Check][Check Badge]][Actions]\n[![Test][Test Badge]][Actions]\n[![Coverage][Coverage Badge]][Coverage]\n\n\u003e *Advent of Code in Python.*\n\n## Installing\n\n**Python 3.8 or above is required.**\n\n### pip\n\nInstalling the library with `pip` is quite simple:\n\n```console\n$ pip install aoc-core\n```\n\nAlternatively, the library can be installed from source:\n\n```console\n$ git clone https://github.com/nekitdev/aoc-core.git\n$ cd aoc-core\n$ python -m pip install .\n```\n\n### poetry\n\nYou can add `aoc-core` as a dependency with the following command:\n\n```console\n$ poetry add aoc-core\n```\n\nOr by directly specifying it in the configuration like so:\n\n```toml\n[tool.poetry.dependencies]\naoc-core = \"^0.2.0\"\n```\n\nAlternatively, you can add it directly from the source:\n\n```toml\n[tool.poetry.dependencies.aoc-core]\ngit = \"https://github.com/nekitdev/aoc-core.git\"\n```\n\n## Extras\n\n`aoc-core` provides an extra `ext`, which installs modules like [`iters`][iters], [`funcs`][funcs]\nand [`wraps`][wraps] which can help solving problems in functional style.\n\n## Example\n\nThis example assumes `aoc` is installed and in `PATH`.\n\nOne also needs to install the `ext` extra to use the `iters` module.\n\nWe will be solving problem the first ever problem of Advent of Code, that is, [`2015-01`][2015-01].\n\nFirstly, we need to make sure we have the token configured:\n\n```console\n$ aoc token print\ntoken not found (path `/home/nekit/.aoc`)\n```\n\nNote that the token is placed in `~/.aoc` by default.\n\nHeading over to the [Advent of Code][Advent of Code] website, we need to trace the requests\nand find the `session` cookie. This is the token we need to add:\n\n```console\n$ aoc token set {TOKEN}\n```\n\nAnd now recheck:\n\n```console\n$ aoc token print\n{TOKEN}\n```\n\nSecondly, we need to download the data for the problem:\n\n```console\n$ aoc download\nYear: 2015\nDay: 01\n(... lots of brackets ...)\n```\n\nAnd we are met by our input data! In order to run the solutions, we need to save this.\n\n```console\n$ aoc download --year 2015 --day 01 --save\n```\n\nOr, if you want to be quicker:\n\n```console\n$ aoc download -y 2015 -d 01 -s\n```\n\nNow we have everything ready to solve the problem!\n\nIn order to define solutions, we need to figure out three types to use:\n\n- `I`, the input type that we parse the data into;\n- `T`, the answer type for the first part of the problem;\n- `U`, the answer type for the second part of the problem.\n\nSince the problem is about navigating the given string and we return integers,\nour types will be: `I = str`, `T = int` and possibly `U = int`.\n\nTo define the solution, we need to derive from [`Solution`][aoc.solutions.Solution]:\n\n```python\n# example.py\n\nfrom aoc.solutions import Solution\n\n\nclass Year2015Day01(Solution[str, int, int]):\n    ...\n```\n\nNote the class name, `Year2015Day01`. This is the convention for naming solutions,\nand all solutions must have their name in the `YearYYYYDayDD` format.\n\nWe also need to define three methods:\n\n- `parse`, which takes the data string and returns `I`;\n- `solve_one`, which takes `I` and returns `T`;\n- `solve_two`, which takes `I` and returns `U`.\n\nPart one is rather simple, we need to count the occurrences of `(` and `)`,\nand subtract the latter from the former:\n\n```python\nfrom typing import Final\n\nfrom aoc.solutions import Solution\n\nUP: Final = \"(\"\nDOWN: Final = \")\"\n\n\nclass Year2015Day01(Solution[str, int, int]):\n    def parse(self, data: str) -\u003e str:\n        return data\n\n    def solve_one(self, input: str) -\u003e int:\n        return input.count(UP) - input.count(DOWN)\n\n    def solve_two(self, input: str) -\u003e int:\n        return 0\n```\n\nSince we don't yet know what part two is about, let's return `0` for now.\n\nTime to run!\n\n```console\n$ aoc run example.py\nresult for `2015-01`\n    answer one: {ONE}\n    answer two: 0\n    parse time: 1.018us\n    solve one time: 41.401us\n    solve two time: 245.0ns\n```\n\nWe have our answer for part one, let's submit it!\n\n```console\n$ aoc submit --year 2015 --day 01 --part 1 {ONE}\nthe answer is correct\n```\n\nBy the way, we can submit the answer directly after running the solution,\nusing the `--submit (-s)` flag.\n\nNow onto part two! We need to find the first position where the floor is `-1`.\n\nNothing too difficult, here is the solution for part two included:\n\n```python\nfrom typing import Final\n\nfrom iters.iters import iter\n\nfrom aoc.solutions import Solution\n\nUP: Final = \"(\"\nDOWN: Final = \")\"\n\nNEVER_REACHED_BASEMENT: Final = \"the basement was never reached\"\n\n\nclass Year2015Day01(Solution[str, int, int]):\n    def parse(self, data: str) -\u003e str:\n        return data\n\n    def solve_one(self, input: str) -\u003e int:\n        return input.count(UP) - input.count(DOWN)\n\n    def solve_two(self, input: str) -\u003e int:\n        up = UP\n        down = DOWN\n\n        floor = 0\n\n        for position, character in iter(input).enumerate_from(1).unwrap():  # one-based indexing\n            if character == up:\n                floor += 1\n\n            if character == down:\n                floor -= 1\n\n            if floor \u003c 0:\n                return position\n\n        raise ValueError(NEVER_REACHED_BASEMENT)\n```\n\nAnd let's run the solution again:\n\n```console\n$ aoc run example.py\nresult for `2015-01`\n    answer one: {ONE}\n    answer two: {TWO}\n    parse time: 989.0ns\n    solve one time: 41.607us\n    solve two time: 59.411us\n```\n\nWe have our answer for part two, let's submit it!\n\n```console\n$ aoc submit -y 2015 -d 01 -p 2 {TWO}\nthe answer is correct\n```\n\nAnd there we go, we have solved the first ever problem in the Advent of Code!\n\n## Documentation\n\nYou can find the documentation [here][Documentation].\n\n## Support\n\nIf you need support with the library, you can send an [email][Email]\nor refer to the official [Discord server][Discord].\n\n## Changelog\n\nYou can find the changelog [here][Changelog].\n\n## Security Policy\n\nYou can find the Security Policy of `aoc-core` [here][Security].\n\n## Contributing\n\nIf you are interested in contributing to `aoc-core`, make sure to take a look at the\n[Contributing Guide][Contributing Guide], as well as the [Code of Conduct][Code of Conduct].\n\n## License\n\n`aoc-core` is licensed under the MIT License terms. See [License][License] for details.\n\n[Email]: mailto:support@nekit.dev\n\n[Discord]: https://nekit.dev/chat\n\n[Actions]: https://github.com/nekitdev/aoc-core/actions\n\n[Changelog]: https://github.com/nekitdev/aoc-core/blob/main/CHANGELOG.md\n[Code of Conduct]: https://github.com/nekitdev/aoc-core/blob/main/CODE_OF_CONDUCT.md\n[Contributing Guide]: https://github.com/nekitdev/aoc-core/blob/main/CONTRIBUTING.md\n[Security]: https://github.com/nekitdev/aoc-core/blob/main/SECURITY.md\n\n[License]: https://github.com/nekitdev/aoc-core/blob/main/LICENSE\n\n[Package]: https://pypi.org/project/aoc-core\n[Coverage]: https://codecov.io/gh/nekitdev/aoc-core\n[Documentation]: https://nekitdev.github.io/aoc-core\n\n[Discord Badge]: https://img.shields.io/discord/728012506899021874\n[License Badge]: https://img.shields.io/pypi/l/aoc-core\n[Version Badge]: https://img.shields.io/pypi/v/aoc-core\n[Downloads Badge]: https://img.shields.io/pypi/dm/aoc-core\n\n[Documentation Badge]: https://github.com/nekitdev/aoc-core/workflows/docs/badge.svg\n[Check Badge]: https://github.com/nekitdev/aoc-core/workflows/check/badge.svg\n[Test Badge]: https://github.com/nekitdev/aoc-core/workflows/test/badge.svg\n[Coverage Badge]: https://codecov.io/gh/nekitdev/aoc-core/branch/main/graph/badge.svg\n\n[iters]: https://github.com/nekitdev/iters\n[funcs]: https://github.com/nekitdev/funcs\n[wraps]: https://github.com/nekitdev/wraps\n\n[Advent of Code]: https://adventofcode.com/\n\n[2015-01]: https://adventofcode.com/2015/day/1\n\n[aoc.solutions.Solution]: https://nekitdev.github.io/aoc-core/reference/solutions#aoc.solutions.Solution\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnekitdev%2Faoc-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnekitdev%2Faoc-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnekitdev%2Faoc-core/lists"}