-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f75f6cb
Showing
24 changed files
with
2,000 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# .flake8 | ||
[flake8] | ||
application-import-names = advent_of_code_2023,tests | ||
select = ANN,B,B9,BLK,C,E,F,I,S,W | ||
ignore = E203,E501,W503 | ||
per-file-ignores = tests/*:S101 | ||
max-complexity = 10 | ||
max-line-length = 88 | ||
exclude = day_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Update README ⭐ | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: geertlitjens/advent-readme-stars@db0643f5b6a1d21cfa2271e08794fdc3a1bdadcd | ||
with: | ||
userId: 553977 | ||
sessionCookie: ${{ secrets.AOC_SESSION }} | ||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Update README stars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.aoc_token | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: local | ||
hooks: | ||
- id: black | ||
name: black | ||
exclude: day_template | ||
entry: poetry run black | ||
language: system | ||
types: [python] | ||
- id: flake8 | ||
name: flake8 | ||
exclude: day_template | ||
entry: poetry run flake8 | ||
language: system | ||
types: [python] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Geert Litjens | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Geert's solutions to the Advent of Code 2023 | ||
|
||
This is the fourth year that I decided to participate in the [Advent of Code](https://adventofcode.com/). I decided to try to also learn some new skills this year, learning more about modern Python and trying to automatically generate a GitHub Pages site with my solutions, which you can find [here](http://geertlitjens.nl/advent-of-code-2023/). | ||
|
||
<!--- advent_readme_stars table ---> | ||
<!--- advent_readme_stars table ---> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
theme: jekyll-theme-midnight | ||
title: "Geert's Advent of Code 2023 solutions in Python" | ||
description: "Trying to solve the Advent of Code puzzles and simultanousnly learn some modern Python techniques and toolchains." | ||
show_downloads: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
--- | ||
|
||
@import "{{ site.theme }}"; | ||
|
||
footer { | ||
display: none !important; | ||
} | ||
|
||
.btn { | ||
display: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
This is the fourth year that I decided to participate in the [Advent of Code](https://adventofcode.com/). Through this | ||
document I try to keep track of my progress and explain my solutions. This main page is manually updated by me, but all | ||
the other pages are generated automatically based on the docstrings I wrote in the code. This page is intended to mostly | ||
explain what Advent of Code is and what tools I chose to solve the puzzles. | ||
|
||
## What is Advent of Code? | ||
So first of, what is the [Advent of Code](https://adventofcode.com/)? Well, as the author, [Eric Wastl](http://was.tl/) | ||
writes: | ||
|
||
>Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. | ||
As such, the Advent of Code is mostly intended as a fun exercise. The idea is that every day at 6AM CET a new puzzle | ||
is released on the AoC website, consisting of two parts. The first part is immediately available and needs to be solved | ||
before you can access the second part. Completing the different parts successfully gives you maximally two starts per day | ||
, with a total of 50 stars. You can access puzzles from other days if you cannot solve the previous day. There are no | ||
hints, except Googling for others' solutions. | ||
|
||
## Solutions | ||
Here you can find my solutions (on [GitHub](https://github.com/GeertLitjens/advent-of-code-2023) as well) for the different days: | ||
|
||
* [Day 1](./days/day1.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[mypy] | ||
exclude = day_template | ||
|
||
[mypy-nox.*,pytest,requests,nox_poetry,colorama,click,numpy] | ||
ignore_missing_imports = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import tempfile | ||
|
||
import nox | ||
from nox_poetry import Session, session | ||
|
||
nox.options.sessions = "lint", "mypy", "safety", "tests" | ||
locations = "src", "tests" | ||
package = "advent_of_code_2023" | ||
|
||
|
||
@session(python=["3.11", "3.8"]) | ||
def tests(session: Session) -> None: | ||
session.install("pytest", "coverage[toml]", "pytest-cov", ".") | ||
session.run("pytest", "--cov") | ||
|
||
|
||
@session(python=["3.10", "3.8"]) | ||
def lint(session: Session) -> None: | ||
args = session.posargs or locations | ||
session.install( | ||
"flake8", | ||
"flake8-annotations", | ||
"flake8-bandit", | ||
"flake8-black", | ||
"flake8-bugbear", | ||
"flake8-isort", | ||
) | ||
session.run("flake8", *args) | ||
|
||
|
||
@session(python="3.11") | ||
def black(session: Session) -> None: | ||
args = session.posargs or locations | ||
args += ("--extend-exclude", "day_template") | ||
session.install("black") | ||
session.run("black", *args) | ||
|
||
|
||
@session(python=["3.11", "3.8"]) | ||
def mypy(session: Session) -> None: | ||
args = session.posargs or locations | ||
session.install("mypy") | ||
session.run("mypy", *args) | ||
|
||
|
||
@session(python="3.8") | ||
def safety(session: Session) -> None: | ||
with tempfile.NamedTemporaryFile() as requirements: | ||
session.run( | ||
"poetry", | ||
"export", | ||
"--dev", | ||
"--format=requirements.txt", | ||
"--without-hashes", | ||
f"--output={requirements.name}", | ||
external=True, | ||
) | ||
session.install("safety") | ||
session.run("safety", "check", f"--file={requirements.name}", "--full-report") | ||
|
||
|
||
@session(python=["3.11", "3.8"]) | ||
def typeguard(session: Session) -> None: | ||
args = session.posargs or ["-m", "not e2e"] | ||
session.install("pytest", "pytest-mock", "typeguard", ".") | ||
session.run("pytest", f"--typeguard-packages={package}", *args) |
Oops, something went wrong.