Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marty777/adventofcode2024
Advent of Code 2024 in Python
https://github.com/marty777/adventofcode2024
advent-of-code advent-of-code-2024 advent-of-code-python
Last synced: 23 days ago
JSON representation
Advent of Code 2024 in Python
- Host: GitHub
- URL: https://github.com/marty777/adventofcode2024
- Owner: marty777
- Created: 2024-12-01T05:10:01.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-09T06:25:12.000Z (26 days ago)
- Last Synced: 2024-12-09T07:26:54.982Z (26 days ago)
- Topics: advent-of-code, advent-of-code-2024, advent-of-code-python
- Language: Python
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# adventofcode2024
[Advent of Code 2024](https://adventofcode.com/2024) in Python.## Setup
```console
$ git clone https://github.com/marty777/adventofcode2024
$ cd adventofcode2024
$ pip install requests
$ pip install argparse
$ python adventofcode2024.py
Setting up configuration...
Enter an Advent of Code session key (optional):
```If an active session key for the Advent of Code website is entered it will be stored in `./config.json` and input files can be automatically downloaded and saved when a puzzle solution is run. Press enter to skip. **If a session key is entered, please make sure not to share your config file with others**.
```console
A configuration file has been created at ./config.json
usage: adventofcode2024 [-h] [-f FILE] day
adventofcode2024: error: the following arguments are required: day
```## Usage
```console
$ python adventofcode2024.py [-h] [-f FILE] daypositional arguments:
day The Advent of Code day # to runoptions:
-h, --help show this help message and exit
-f FILE, --file FILE Input file. If not specified the file ./data/day#/input.txt will be run
```Any input file can be passed in with the `-f` option. By default, the script expects the main input file for a puzzle day to be at the path `./data/day#/input.txt` (e.g. `./data/day1/input.txt` for day 1) and will attempt to load the input file corresponding to the day if no file is otherwise specified. The path for the default data directory can be modified in `./config.json`. If an Advent of Code session key has been configured, the input file for the day will be automatically downloaded to the default input file location if not already present.
## Example
To run day 1:
```console
$ python adventofcode2024.py -f data/day1/input.txt 1
```With the default data directory config setting, this is equivalent to
```console
$ python adventofcode2024.py 1
```If an Advent of Code session key has been configured, the input file for the specified day will be automatically downloaded and saved to the expected location. If not, the `input.txt` file for the intended day should be manually saved first.