{"id":22558001,"url":"https://github.com/jd-apprentice/aoc_2024","last_synced_at":"2025-03-28T11:28:14.484Z","repository":{"id":265958471,"uuid":"896933300","full_name":"jd-apprentice/aoc_2024","owner":"jd-apprentice","description":"https://adventofcode.com/2024","archived":false,"fork":false,"pushed_at":"2024-12-03T23:13:06.000Z","size":1432,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T02:51:21.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/jd-apprentice.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-12-01T16:58:09.000Z","updated_at":"2024-12-03T23:13:09.000Z","dependencies_parsed_at":"2024-12-02T02:02:41.525Z","dependency_job_id":null,"html_url":"https://github.com/jd-apprentice/aoc_2024","commit_stats":null,"previous_names":["jd-apprentice/aoc_2024"],"tags_count":0,"template":false,"template_full_name":"wlachs/advent_of_code_go_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-apprentice%2Faoc_2024","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-apprentice%2Faoc_2024/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-apprentice%2Faoc_2024/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jd-apprentice%2Faoc_2024/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jd-apprentice","download_url":"https://codeload.github.com/jd-apprentice/aoc_2024/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246020193,"owners_count":20710704,"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":[],"created_at":"2024-12-07T20:10:36.652Z","updated_at":"2025-03-28T11:28:14.462Z","avatar_url":"https://github.com/jd-apprentice.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Advent of Code Project Template\n\nA lightweight execution environment for the [advent of code](https://adventofcode.com/) challenges written in Go.\n\n## Get started\n\nIn the following section, I'll show you how to set up and run the environment for the challenges.\n\n### Prerequisites\n\nMake sure you have Go \u003e= 1.21.4 installed.\n\n### Clone the repository\n\n```sh\ngit clone https://github.com/wlchs/advent_of_code_go_template\n```\n\n### Solving the daily challenges\n\nI've generated a separate directory in the repository for each advent calendar day: from the 1st until the 25th. Additionally, the `day_0`\ndirectory contains a solution for the first challenge from last year's competition.\n\nTo solve a daily challenge, navigate to the corresponding day and implement the solution. I've prepared two methods for each day, `Part1`\nand`Part2`, indicating that every challenge has two parts. The return value of the methods are always strings. The methods receive the input\nas a string slice, so you don't have to worry about reading anything from a file.\n\nThe solution for the challenge of December 1, 2022, looks like this:\n\n```go\n\n// getElfCalories reads the input lines and returns a slice of calories for each elf\nfunc getElfCalories(input []string) []int {\n    var calories []int\n    currentElf := 0\n    for _, i := range input {\n        if i == \"\" {\n            calories = append(calories, currentElf)\n            currentElf = 0\n        } else {\n            cal, _ := strconv.Atoi(i)\n            currentElf += cal\n        }\n    }\n    calories = append(calories, currentElf)\n    sort.Slice(calories, func (i, j int) bool {\n        return calories[i] \u003e calories[j]\n    })\n    return calories\n}\n\n// Part1 solves the first part of the exercise\nfunc Part1(input []string) string {\n    calories := getElfCalories(input)\n    maxCalories := calories[0]\n    return strconv.Itoa(maxCalories)\n}\n\n// Part2 solves the second part of the exercise\nfunc Part2(input []string) string {\n    calories := getElfCalories(input)\n\n    topCalories := 0\n    for _, i := range calories[:3] {\n        topCalories += i\n    }\n\n    return strconv.Itoa(topCalories)\n}\n\n```\n\nAdditionally, I've prepared unit tests for each day to try the solutions with a template input. The text files in the directories contain\nthe template input and output for both parts of the exercise. Paste the input to `input_test_x.txt` file and the expected solution\nto`solution_x.txt`.\n\n### Test your solution\n\nBefore submitting a solution, you can test your algorithm with the template input. Navigate to the day you want to check and run the\nfollowing command:\n\n```sh\ngo test\n```\n\nAlternatively, you can also run the command from the project root.\n\n```sh\ngo test ./days/day_xx/\n```\n\n### Compile and run\n\nYou can compile code and run with the actual input if all the tests pass. For this, first, run this command:\n\n```sh\ngo build .\n```\n\nTo run the solution, you need to provide a few extra arguments.\n* the `--day` flag must be set to specify which day's solution should run\n* the `--input` flag specifies the path of the file containing the actual input\n* optionally, you can add the `--mode` flag to run one part of the daily challenge, accepted values are 1 and 2\n\nAnd now the complete command:\n\n```sh\n./advent_of_code_go_template --day x --input path_to_input --mode 1\n# or\ngo run . --day x --input path_to_input --mode 1\n```\n\n## Contribution\n\nIf you'd like to contribute to the project, open an issue or a pull request!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjd-apprentice%2Faoc_2024","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjd-apprentice%2Faoc_2024","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjd-apprentice%2Faoc_2024/lists"}