https://github.com/heman/aoc2024
https://github.com/heman/aoc2024
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/heman/aoc2024
- Owner: HeMan
- Created: 2024-11-06T16:29:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-02T08:18:18.000Z (over 1 year ago)
- Last Synced: 2025-02-03T09:20:01.288Z (over 1 year ago)
- Language: Dockerfile
- Size: 1.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example repo for the Cygnified Advent of Code
This repo is an example showing how to structure your own repo in a way that your solutions on [Advent of Code](https://adventofcode.com/) can be analyzed correctly on the [Cygnified version](https://aoc-2022.cygni.se).
## Folder structure
Your solutions must be placed in a folder corresponding to the day that the solutions belong to; `day01`, `day02` etc. There's a script called `create_directories.sh` which you can use to generate all 25 days. Or, if you want you can just execute this in the root of your repo:
```for i in $(seq -w 1 25); do mkdir "day$i"; done```
## Dockerfile to measure execution time
In order to measure execution time, every solultion needs to be place in a `Dockerfile`. This needs to contain a command (`CMD`) that triggers a run of your solution. `Dockerfile` must also copy a file named `./input.txt` so that your solution has access to the input data. We will then build the image and execute the following:
```
$ docker build -t "${dockerImage}" .
$ docker run -e part=part1 "${dockerImage}"
```
As an alternative to docker during development, you can use [podman](https://podman.io/), which has the same commands.
### Environment variable for the two parts
As you can see in the example above, the execution time is measured using the environment variable `part`. Every day, there will be a part 1 and part 2 on Advent of Code. Please have a look at the examples (`day01` etc) to see how you can solve this. It's important that the environment variable is setup correctly in order to measure time. We measure time by running
```
$ docker run -e part=part1 "${dockerImage}"
```
And then inspecting the Docker container something like this:
```
START=$(docker inspect --format='{{.State.StartedAt}}' $CONTAINER_ID)
STOP=$(docker inspect --format='{{.State.FinishedAt}}' $CONTAINER_ID)
START_TIMESTAMP=$(date --date=$START +%s%N)
STOP_TIMESTAMP=$(date --date=$STOP +%s%N)
echo $((($STOP_TIMESTAMP-$START_TIMESTAMP)/1000000))
```
## Examples of correct structure
All folders in this repo (`day01` etc) contains a simple but correct setup. Please have a look at it.
## Puzzle example and solutions in many different languages
You'll find [here](./examples)
## Any questions?
Don't fret. Let us know in [#adventofcode](https://cygni.slack.com/archives/C87HA2UNL). We're all here to help each other and have fun!