Skip to content

Commit

Permalink
chore: remove git stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Joehoel committed Nov 28, 2022
1 parent 3d6a20d commit 112f0b9
Show file tree
Hide file tree
Showing 95 changed files with 3,946 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md → 2021/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## All code for advent of code 2021

### TODO

- [ ] write cli for running a file like: `deno task run 1 1`

---

Joël Kuijper
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions 2022/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build]
rustflags = ["-C", "target-cpu=native"]

[alias]
rr = "run --release"
16 changes: 16 additions & 0 deletions 2022/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true

[*]
indent_size = 4
indent_style = space
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.txt]
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
20 changes: 20 additions & 0 deletions 2022/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb


# Added by cargo

/target

# Advent of Code
# @see https://old.reddit.com/r/adventofcode/comments/k99rod/sharing_input_data_were_we_requested_not_to/gf2ukkf/?context=3
inputs
!inputs/.keep
64 changes: 64 additions & 0 deletions 2022/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'aoc'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=aoc",
"--package=aoc"
],
"filter": {
"name": "aoc",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'aoc'",
"cargo": {
"args": [
"build",
"--bin=aoc",
"--package=aoc"
],
"filter": {
"name": "aoc",
"kind": "bin"
}
},
"args": ["1"],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'aoc'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=aoc"
],
"filter": {
"name": "aoc",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
25 changes: 25 additions & 0 deletions 2022/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions 2022/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "aoc"
version = "0.1.0"
authors = ["Felix Spöttel <[email protected]>"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[profile.release]
lto = "thin"

[dependencies]
itertools = "0.10.1"
21 changes: 21 additions & 0 deletions 2022/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Felix Spoettel

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.
121 changes: 121 additions & 0 deletions 2022/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<img src="./assets/christmas_ferris.png" width="164" align="center">

# 🎄 [Advent of Code](https://adventofcode.com/)

![Language](https://badgen.net/badge/Language/Rust/orange)

<!--- advent_readme_stars table --->

## 2022 Results

| Day | Part 1 | Part 2 |
| :--------------------------------------------: | :----: | :----: |
| [Day 1](https://adventofcode.com/2021/day/1) |||
| [Day 2](https://adventofcode.com/2021/day/2) |||
| [Day 3](https://adventofcode.com/2021/day/3) |||
| [Day 4](https://adventofcode.com/2021/day/4) |||
| [Day 5](https://adventofcode.com/2021/day/5) |||
| [Day 6](https://adventofcode.com/2021/day/6) |||
| [Day 7](https://adventofcode.com/2021/day/7) |||
| [Day 8](https://adventofcode.com/2021/day/8) |||
| [Day 9](https://adventofcode.com/2021/day/9) |||
| [Day 10](https://adventofcode.com/2021/day/10) |||
| [Day 11](https://adventofcode.com/2021/day/11) |||
| [Day 12](https://adventofcode.com/2021/day/12) |||
| [Day 13](https://adventofcode.com/2021/day/13) |||
| [Day 14](https://adventofcode.com/2021/day/14) |||
| [Day 15](https://adventofcode.com/2021/day/15) |||
| [Day 16](https://adventofcode.com/2021/day/16) |||
| [Day 17](https://adventofcode.com/2021/day/17) |||
| [Day 18](https://adventofcode.com/2021/day/18) |||
| [Day 19](https://adventofcode.com/2021/day/19) |||
| [Day 20](https://adventofcode.com/2021/day/20) |||
| [Day 21](https://adventofcode.com/2021/day/21) |||
| [Day 22](https://adventofcode.com/2021/day/22) |||
| [Day 23](https://adventofcode.com/2021/day/23) |||
| [Day 24](https://adventofcode.com/2021/day/24) |||
| [Day 25](https://adventofcode.com/2021/day/25) |||

<!--- advent_readme_stars table --->

---

Generated with the [advent-of-code-rust](https://github.com/fspoettel/advent-of-code-rust) template.

## Commands

### Setup new day

```sh
# example: `./scripts/scaffold.sh 1`
./scripts/scaffold.sh <day>

# output:
# Created module `src/solutions/day01.rs`
# Created input file `src/inputs/day01.txt`
# Created example file `src/examples/day01.txt`
# Linked new module in `src/main.rs`
# Linked new module in `src/solutions/mod.rs`
# Done! 🎄
```

Every solution file has _unit tests_ referencing the example input file. You can use these tests to develop and debug your solution. When editing a solution file, `rust-analyzer` will display buttons for these actions above the unit tests.

### Download inputs for a day

```sh
# example: `./scripts/download.sh 1`
./scripts/download.sh <day>

# output:
# Invoking `aoc` cli...
# Loaded session cookie from "/home/foo/.adventofcode.session".
# Downloading input for day 1, 2021...
# Saving puzzle input to "/tmp/..."...
# Done!
# Wrote input to `src/inputs/day01.txt`...
# Done! 🎄
```

Puzzle inputs are not checked into git. [See here](https://old.reddit.com/r/adventofcode/comments/k99rod/sharing_input_data_were_we_requested_not_to/gf2ukkf/?context=3) why.

### Run solutions for a day

```sh
# example: `cargo run 1`
cargo run <day>

# output:
# Running `target/debug/aoc 1`
# ----
#
# 🎄 Part 1 🎄
#
# 6 (elapsed: 37.03µs)
#
# 🎄 Part 2 🎄
#
# 9 (elapsed: 33.18µs)
#
# ----
```

To run an optimized version for benchmarking, use the `--release` flag or the alias `cargo rr <day>`.

### Run all solutions against example input

```sh
cargo test
```

### Format code

```sh
cargo fmt
```

### Lint code

```sh
cargo clippy
```
Binary file added 2022/assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2022/assets/christmas_ferris.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions 2022/scripts/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -e;

if ! command -v 'aoc' &> /dev/null
then
echo "command \`aoc\` not found. Try running \`cargo install aoc-cli\` to install it."
exit 1
fi

if [ ! -n "$1" ]; then
>&2 echo "Argument is required for day."
exit 1
fi

day=$(echo $1 | sed 's/^0*//');
day_padded=`printf %02d $day`;

filename="day$day_padded";
input_path="src/inputs/$filename.txt";

tmp_dir=$(mktemp -d);
tmp_file_path="$tmp_dir/input";

aoc download --day $day --file $tmp_file_path;
cat $tmp_file_path > $input_path;
echo "Wrote input to \"$input_path\"...";

cat <<EOF
_==_ _
_,(",)|_|
\/. \-|
__( : )|_ Done!
EOF

# Make sure it gets removed even if the script exits abnormally.
trap "exit 1" HUP INT PIPE QUIT TERM
trap 'rm -rf "$tmp_dir"' EXIT
Loading

0 comments on commit 112f0b9

Please sign in to comment.