{"id":22150379,"url":"https://github.com/tomcat-42/aoc.zig-template","last_synced_at":"2025-07-26T04:31:08.185Z","repository":{"id":263890991,"uuid":"891249955","full_name":"Tomcat-42/aoc.zig-template","owner":"Tomcat-42","description":"Advent of Code Zig Template","archived":false,"fork":false,"pushed_at":"2024-12-01T13:41:13.000Z","size":32,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-01T14:31:57.357Z","etag":null,"topics":["advent-of-code","advent-of-code-zig","aoc","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tomcat-42.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-20T01:57:55.000Z","updated_at":"2024-12-01T13:41:17.000Z","dependencies_parsed_at":"2024-11-20T21:40:56.048Z","dependency_job_id":null,"html_url":"https://github.com/Tomcat-42/aoc.zig-template","commit_stats":null,"previous_names":["tomcat-42/aoc.zig-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomcat-42%2Faoc.zig-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomcat-42%2Faoc.zig-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomcat-42%2Faoc.zig-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomcat-42%2Faoc.zig-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tomcat-42","download_url":"https://codeload.github.com/Tomcat-42/aoc.zig-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227647759,"owners_count":17798596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["advent-of-code","advent-of-code-zig","aoc","zig","ziglang"],"created_at":"2024-12-02T00:15:14.135Z","updated_at":"2024-12-02T00:15:15.848Z","avatar_url":"https://github.com/Tomcat-42.png","language":"Zig","readme":"# aoc.zig-template\n\nThis is a zig template for Advent of Code. It has a very opinionated structure\nand automatic input fetching/source code template generation for a current year/day.\nAll of this is powered by the **zig build system**.\n\n## Usage\n\nClone this template repo:\n\n```bash\ngh repo create aoc.zig --template Tomcat-42/aoc.zig-template --public --clone\n```\n\nThen Login to your [Advent of Code](https://adventofcode.com/) account to get your session\ntoken. You can do that by opening the browser devtools, selecting the networks tab, reloading\nthe page, selecting any request and looking for the `Cookie: session=\u003cTOKEN\u003e` header:\n\n![image](https://github.com/user-attachments/assets/8ee0e200-1e00-451d-8309-3a18d94ed3af)\n\nThen, make it available as an env var:\n\n```bash\nAOC_SESSION_TOKEN=\"\u003cTOKEN\u003e\"\n```  \n\nYou can pass the command line flags `-Dyear=\u003cyear\u003e` and `-Dday=\u003cday\u003e` \nto specify the year and day you want to generate the template for \n(if you don't pass them, it will default to the current year and day of the month).\n\n```sh\nzig build --build-runner build_runner.zig -Dyear=2023 -Dday=1 --watch run\n```\n\nYou can pass `test` instead of run to run the unit tests instead:\n```sh\nzig build --build-runner build_runner.zig -Dyear=2023 -Dday=1 --watch test\n```\n\n## Details\n\nWhen you run the build command for a year and day for the first time,\nit generates the source code template (`./src/\u003cyear\u003e/\u003cday\u003e.zig`) and input \n(`./input/\u003cyear\u003e/\u003cday\u003e.txt`) for that year/day. \n\nThe `./src/\u003cyear\u003e/\u003cday\u003e.zig` file will have the following format:\n\n```zig\nconst std = @import(\"std\");\nconst mem = std.mem;\n\ninput: []const u8,\nallocator: mem.Allocator,\n\npub fn part1(this: *const @This()) !?i64 {\n    _ = this;\n    return null;\n}\n\npub fn part2(this: *const @This()) !?i64 {\n    _ = this;\n    return null;\n}\n\ntest \"it should do nothing\" {\n    const allocator = std.testing.allocator;\n    const input = \"\";\n\n    const problem: @This() = .{\n        .input = input,\n        .allocator = allocator,\n    };\n\n    try std.testing.expectEqual(null, try problem.part1());\n    try std.testing.expectEqual(null, try problem.part2());\n}\n```\n\nYou \"solve\" the problem by returning the solution from `part1` and `part2` function.\nThe `input` field is the input data for the problem (see `build.zig` and `src/main.zig` \nfor details on how this is achieved). Note that you can return anything as the solution,\nfor instance, if the solution is a string, you can return a `[]const u8` from any part.\n\nAdd tests for small examples and edge cases in tests blocks at the end of the file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomcat-42%2Faoc.zig-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomcat-42%2Faoc.zig-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomcat-42%2Faoc.zig-template/lists"}