Compare commits

..

10 Commits

19 changed files with 7051 additions and 1 deletions

View File

@ -2,7 +2,7 @@
## About
These are my solutions to the Advent of Code 2022.
These are my solutions to the Advent of Code 2022. This year I'm attempting to code the solutions in Rust to punish myself. I still dislike Rust.
## Author

14
rust/.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

9
rust/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "aoc2022"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
regex = "1"

8
rust/make.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
DIR="$(dirname "$0")"
if cargo "$@"; then
[ -d "$DIR/target/debug" ] && cp -r "$DIR/resources" "$DIR/target/debug/resources"
[ -d "$DIR/target/release" ] && cp -r "$DIR/resources" "$DIR/target/release/resources"
fi

2242
rust/resources/day1input.txt Normal file

File diff suppressed because it is too large Load Diff

2500
rust/resources/day2input.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,300 @@
dWlhclDHdFvDCCDfFq
mGdZBZBwRGjZMFgvTvgtvv
jwwJrzdzGdSbGGnNlzWczHzPHPhn
cczcbMBszhzzDBTBPPPGjtvtlt
LqJLfpwdLnvQLRGQjGtj
gSgnSJJCGSGpGSrwgfhchmmmHzcrHDmbrmMm
bVjstCsSstCLCrbSLnMpdMndcLddcqcpHR
wPZJQJwtBfJZmgBwPTcpTdcnfHMppcGMdG
gmFJzwPJJtszvNhCNC
DmjZDMZWDqGRqqRpHmmRLTTNTPTfCQJQQLJHTClc
FtzfvrfFwVgtzztgBLJNcNlTcTVNNQLN
vgsdbzzrwtqWfW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L
dvdTMvvpdLpTcSLvdLLMmhfFBftwCNhRwRNjtCTRCf
lshQWgsgrHHqlFfRqFjRFfFwCB
rsgHQbJbrsGHHlgQHgJrlHrPZdhdpMZGDSDpdPLcZhdvhZ

1000
rust/resources/day4input.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2

View File

@ -0,0 +1,512 @@
[Q] [B] [H]
[F] [W] [D] [Q] [S]
[D] [C] [N] [S] [G] [F]
[R] [D] [L] [C] [N] [Q] [R]
[V] [W] [L] [M] [P] [S] [M] [M]
[J] [B] [F] [P] [B] [B] [P] [F] [F]
[B] [V] [G] [J] [N] [D] [B] [L] [V]
[D] [P] [R] [W] [H] [R] [Z] [W] [S]
1 2 3 4 5 6 7 8 9
move 1 from 4 to 1
move 2 from 4 to 8
move 5 from 9 to 6
move 1 from 1 to 3
move 5 from 8 to 3
move 1 from 1 to 5
move 4 from 3 to 6
move 14 from 6 to 2
move 5 from 4 to 5
move 7 from 7 to 2
move 24 from 2 to 3
move 13 from 3 to 2
move 1 from 7 to 9
move 1 from 9 to 5
move 7 from 2 to 6
move 3 from 1 to 7
move 3 from 6 to 3
move 2 from 7 to 1
move 1 from 7 to 5
move 2 from 2 to 6
move 2 from 1 to 4
move 9 from 5 to 1
move 1 from 6 to 3
move 4 from 5 to 4
move 1 from 2 to 7
move 4 from 6 to 2
move 7 from 2 to 3
move 2 from 2 to 6
move 2 from 2 to 3
move 2 from 5 to 4
move 1 from 7 to 3
move 4 from 6 to 7
move 19 from 3 to 6
move 3 from 7 to 4
move 1 from 7 to 8
move 1 from 8 to 1
move 2 from 1 to 3
move 10 from 3 to 2
move 3 from 3 to 8
move 1 from 3 to 9
move 1 from 9 to 6
move 11 from 6 to 8
move 2 from 3 to 8
move 6 from 4 to 3
move 3 from 4 to 1
move 7 from 2 to 8
move 1 from 3 to 6
move 6 from 8 to 5
move 1 from 4 to 6
move 9 from 6 to 9
move 6 from 3 to 8
move 1 from 3 to 5
move 10 from 1 to 3
move 11 from 8 to 7
move 1 from 3 to 5
move 1 from 1 to 8
move 5 from 9 to 2
move 1 from 6 to 3
move 5 from 3 to 6
move 1 from 3 to 5
move 4 from 6 to 4
move 1 from 5 to 9
move 6 from 2 to 4
move 2 from 2 to 9
move 5 from 5 to 1
move 2 from 1 to 7
move 10 from 8 to 3
move 1 from 8 to 6
move 3 from 6 to 3
move 6 from 4 to 2
move 8 from 3 to 8
move 3 from 4 to 8
move 4 from 2 to 1
move 3 from 5 to 3
move 4 from 7 to 6
move 2 from 9 to 3
move 1 from 2 to 9
move 1 from 2 to 3
move 2 from 4 to 8
move 1 from 7 to 9
move 5 from 7 to 8
move 2 from 7 to 3
move 14 from 3 to 2
move 3 from 9 to 5
move 1 from 3 to 1
move 1 from 7 to 4
move 3 from 9 to 8
move 7 from 8 to 9
move 7 from 2 to 5
move 2 from 3 to 7
move 2 from 7 to 6
move 16 from 8 to 9
move 4 from 6 to 5
move 1 from 2 to 5
move 21 from 9 to 5
move 3 from 9 to 3
move 6 from 1 to 4
move 1 from 1 to 9
move 1 from 1 to 4
move 2 from 6 to 3
move 3 from 4 to 6
move 3 from 4 to 8
move 1 from 9 to 4
move 2 from 4 to 6
move 4 from 3 to 6
move 1 from 3 to 4
move 1 from 4 to 9
move 1 from 9 to 8
move 1 from 8 to 6
move 6 from 2 to 1
move 2 from 8 to 4
move 6 from 1 to 8
move 23 from 5 to 9
move 1 from 4 to 7
move 1 from 7 to 1
move 22 from 9 to 7
move 4 from 8 to 7
move 1 from 5 to 2
move 1 from 1 to 9
move 2 from 8 to 4
move 6 from 6 to 3
move 2 from 9 to 5
move 18 from 7 to 4
move 18 from 4 to 5
move 1 from 2 to 7
move 1 from 8 to 4
move 6 from 7 to 2
move 5 from 4 to 5
move 1 from 3 to 1
move 1 from 7 to 2
move 4 from 3 to 4
move 1 from 3 to 4
move 1 from 1 to 7
move 1 from 5 to 8
move 3 from 4 to 3
move 3 from 3 to 8
move 2 from 8 to 3
move 2 from 4 to 8
move 2 from 7 to 5
move 1 from 7 to 9
move 2 from 3 to 1
move 1 from 9 to 7
move 4 from 2 to 3
move 1 from 8 to 9
move 2 from 1 to 8
move 2 from 2 to 4
move 1 from 9 to 1
move 4 from 6 to 8
move 1 from 2 to 7
move 1 from 4 to 7
move 4 from 8 to 2
move 1 from 4 to 3
move 1 from 1 to 9
move 4 from 8 to 1
move 2 from 2 to 1
move 3 from 3 to 9
move 2 from 7 to 1
move 32 from 5 to 1
move 1 from 8 to 7
move 6 from 5 to 1
move 2 from 7 to 6
move 1 from 9 to 5
move 1 from 3 to 2
move 1 from 5 to 9
move 2 from 6 to 1
move 1 from 3 to 7
move 1 from 9 to 8
move 36 from 1 to 4
move 1 from 8 to 9
move 5 from 4 to 9
move 6 from 9 to 3
move 2 from 2 to 9
move 3 from 1 to 9
move 1 from 3 to 2
move 30 from 4 to 8
move 1 from 7 to 5
move 1 from 3 to 5
move 3 from 3 to 4
move 2 from 8 to 5
move 3 from 9 to 8
move 3 from 9 to 3
move 19 from 8 to 6
move 2 from 3 to 5
move 3 from 4 to 3
move 1 from 4 to 7
move 8 from 1 to 8
move 1 from 3 to 2
move 1 from 7 to 6
move 4 from 5 to 3
move 1 from 1 to 7
move 2 from 5 to 4
move 1 from 9 to 4
move 12 from 6 to 2
move 1 from 7 to 8
move 6 from 2 to 9
move 3 from 6 to 7
move 2 from 7 to 5
move 6 from 2 to 3
move 8 from 3 to 5
move 5 from 6 to 8
move 5 from 3 to 6
move 1 from 9 to 4
move 1 from 9 to 8
move 5 from 5 to 9
move 3 from 4 to 6
move 1 from 4 to 9
move 1 from 7 to 5
move 1 from 3 to 5
move 8 from 9 to 2
move 3 from 9 to 6
move 27 from 8 to 2
move 10 from 6 to 9
move 1 from 6 to 4
move 1 from 4 to 9
move 2 from 5 to 6
move 5 from 5 to 3
move 2 from 6 to 9
move 5 from 3 to 2
move 12 from 9 to 3
move 5 from 3 to 1
move 3 from 1 to 5
move 1 from 9 to 8
move 1 from 5 to 2
move 1 from 2 to 1
move 1 from 1 to 6
move 1 from 5 to 3
move 34 from 2 to 4
move 8 from 3 to 9
move 1 from 6 to 1
move 1 from 8 to 5
move 4 from 2 to 8
move 3 from 8 to 7
move 1 from 7 to 2
move 7 from 9 to 8
move 1 from 9 to 6
move 2 from 5 to 1
move 1 from 6 to 9
move 1 from 9 to 5
move 2 from 2 to 5
move 5 from 8 to 6
move 2 from 8 to 5
move 1 from 1 to 3
move 12 from 4 to 6
move 2 from 7 to 1
move 4 from 1 to 6
move 3 from 2 to 3
move 1 from 8 to 5
move 1 from 2 to 6
move 1 from 1 to 9
move 1 from 9 to 5
move 16 from 4 to 1
move 4 from 3 to 1
move 8 from 1 to 8
move 1 from 4 to 1
move 6 from 5 to 8
move 1 from 5 to 7
move 12 from 6 to 9
move 7 from 1 to 5
move 2 from 1 to 7
move 1 from 7 to 1
move 9 from 9 to 6
move 15 from 6 to 2
move 2 from 9 to 7
move 4 from 4 to 5
move 2 from 2 to 9
move 3 from 7 to 5
move 2 from 1 to 3
move 1 from 7 to 1
move 10 from 2 to 3
move 6 from 8 to 6
move 3 from 9 to 2
move 14 from 5 to 6
move 1 from 8 to 4
move 5 from 8 to 2
move 2 from 2 to 3
move 24 from 6 to 1
move 3 from 1 to 2
move 9 from 2 to 9
move 1 from 4 to 3
move 1 from 4 to 2
move 1 from 8 to 4
move 23 from 1 to 4
move 3 from 2 to 4
move 2 from 1 to 2
move 1 from 8 to 4
move 3 from 3 to 5
move 3 from 3 to 4
move 3 from 5 to 8
move 3 from 2 to 7
move 2 from 3 to 8
move 15 from 4 to 3
move 2 from 4 to 1
move 19 from 3 to 9
move 1 from 7 to 2
move 1 from 2 to 5
move 1 from 5 to 4
move 1 from 7 to 6
move 1 from 7 to 4
move 3 from 8 to 3
move 1 from 8 to 4
move 5 from 3 to 8
move 1 from 3 to 6
move 22 from 9 to 2
move 17 from 2 to 6
move 3 from 9 to 3
move 9 from 4 to 9
move 6 from 4 to 9
move 5 from 2 to 6
move 1 from 4 to 2
move 1 from 4 to 9
move 1 from 1 to 6
move 19 from 9 to 2
move 4 from 8 to 7
move 1 from 1 to 5
move 1 from 5 to 3
move 1 from 8 to 1
move 1 from 8 to 2
move 4 from 3 to 7
move 12 from 6 to 1
move 3 from 7 to 3
move 7 from 2 to 7
move 9 from 2 to 6
move 4 from 2 to 6
move 13 from 1 to 4
move 8 from 6 to 4
move 16 from 4 to 8
move 12 from 7 to 6
move 3 from 8 to 3
move 1 from 1 to 2
move 4 from 3 to 8
move 5 from 8 to 9
move 27 from 6 to 8
move 2 from 3 to 7
move 2 from 2 to 8
move 2 from 7 to 5
move 1 from 5 to 9
move 1 from 5 to 1
move 1 from 6 to 9
move 2 from 6 to 2
move 2 from 2 to 6
move 2 from 9 to 2
move 3 from 4 to 3
move 1 from 1 to 9
move 5 from 9 to 8
move 1 from 9 to 5
move 2 from 2 to 6
move 2 from 4 to 6
move 1 from 3 to 7
move 1 from 5 to 6
move 1 from 6 to 7
move 6 from 6 to 8
move 2 from 7 to 5
move 2 from 3 to 2
move 34 from 8 to 1
move 1 from 5 to 6
move 1 from 5 to 3
move 1 from 6 to 1
move 32 from 1 to 8
move 23 from 8 to 4
move 1 from 2 to 1
move 24 from 8 to 4
move 1 from 3 to 6
move 47 from 4 to 6
move 2 from 6 to 1
move 3 from 1 to 5
move 1 from 2 to 1
move 3 from 5 to 7
move 21 from 6 to 2
move 3 from 7 to 8
move 2 from 1 to 6
move 8 from 6 to 4
move 4 from 8 to 9
move 3 from 2 to 8
move 4 from 4 to 2
move 2 from 2 to 5
move 4 from 9 to 8
move 2 from 1 to 5
move 11 from 6 to 1
move 14 from 2 to 6
move 2 from 4 to 3
move 1 from 2 to 9
move 3 from 2 to 9
move 20 from 6 to 5
move 2 from 4 to 2
move 4 from 9 to 1
move 8 from 8 to 9
move 1 from 6 to 9
move 14 from 5 to 2
move 10 from 2 to 7
move 7 from 9 to 6
move 1 from 6 to 8
move 6 from 2 to 6
move 1 from 2 to 5
move 1 from 3 to 5
move 9 from 6 to 3
move 1 from 5 to 2
move 9 from 7 to 3
move 12 from 3 to 2
move 9 from 5 to 9
move 1 from 8 to 6
move 3 from 3 to 5
move 1 from 7 to 6
move 14 from 2 to 6
move 3 from 9 to 7
move 6 from 1 to 2
move 5 from 1 to 8
move 10 from 6 to 9
move 4 from 5 to 6
move 3 from 2 to 4
move 9 from 9 to 7
move 1 from 8 to 7
move 3 from 9 to 6
move 3 from 3 to 7
move 1 from 5 to 1
move 15 from 7 to 1
move 2 from 8 to 5
move 2 from 5 to 4
move 1 from 7 to 4
move 1 from 3 to 1
move 15 from 6 to 7
move 2 from 4 to 9
move 3 from 4 to 7
move 18 from 1 to 6
move 1 from 8 to 9
move 6 from 9 to 7
move 3 from 6 to 8
move 1 from 1 to 2
move 2 from 9 to 5
move 2 from 2 to 9
move 16 from 6 to 3
move 15 from 3 to 7
move 2 from 8 to 4
move 1 from 3 to 7
move 3 from 4 to 9
move 2 from 1 to 9
move 26 from 7 to 4
move 1 from 2 to 1
move 7 from 9 to 8
move 1 from 2 to 5
move 2 from 5 to 2
move 8 from 7 to 5
move 1 from 7 to 3
move 1 from 3 to 9
move 2 from 2 to 7
move 1 from 6 to 4
move 4 from 8 to 9
move 1 from 1 to 3
move 1 from 5 to 6
move 2 from 5 to 7
move 17 from 4 to 9
move 6 from 4 to 9
move 1 from 3 to 4
move 6 from 7 to 9
move 3 from 5 to 6
move 2 from 7 to 9
move 4 from 8 to 9
move 4 from 6 to 4
move 8 from 4 to 6
move 1 from 8 to 4
move 3 from 5 to 2
move 2 from 4 to 3
move 1 from 7 to 9
move 2 from 3 to 5
move 4 from 6 to 9
move 1 from 6 to 1
move 36 from 9 to 4
move 2 from 5 to 3
move 3 from 2 to 1
move 3 from 1 to 4
move 14 from 4 to 1
move 1 from 8 to 5
move 4 from 1 to 3
move 5 from 9 to 5
move 2 from 5 to 8
move 1 from 8 to 9
move 4 from 9 to 6
move 3 from 5 to 8
move 1 from 5 to 6
move 2 from 1 to 6
move 2 from 9 to 7
move 6 from 6 to 4
move 1 from 1 to 3
move 29 from 4 to 6
move 7 from 3 to 4
move 1 from 8 to 9
move 3 from 1 to 6
move 4 from 1 to 4
move 1 from 8 to 4
move 4 from 4 to 3
move 15 from 6 to 8
move 9 from 4 to 9
move 1 from 7 to 9
move 8 from 8 to 3
move 3 from 6 to 7
move 1 from 1 to 2
move 4 from 7 to 6
move 7 from 8 to 5
move 1 from 8 to 4
move 2 from 5 to 7
move 1 from 2 to 4
move 5 from 6 to 1
move 4 from 3 to 2

View File

@ -0,0 +1 @@
bgdbdsbsbsttldddzzwnzzmpzmmzmqqcgglrglgbbbtmtddrssjtjqqtrtqtqppcvcddswdwbwlblfljfljlhhpchcfcgfcfwfllfccjlcjllbvbgglccznzrnzzvfzvffvzvccnwnnrtrqtttzmmndnqnvvlwvvgcclplccbggcscqscqcnndwdlwlvlffdssrzrtttbvvqttfdfrddhthbblnlmlmqmhhpvpcpwpccmdddbcbcgctggsstwwbcwwqllchlcccfwccvjcjhhvggnvvcssjwjhhdvdhdcdhdqhhwrwcrwcrrjzjccqhhvnnrppsqqplqqcvczzlpprlrqqvpvwwstwwzqqsnqqsrqrlqlggzztzhhvbbcncwnwhwbbqpbqpqdqsqjqrjrddpjpwwvlwlnwwmpwwnmmzgzqqdcdnnqllghhzwhwwggljjwswgwffsbffbggzfzcfzczpptrrnwrrcqqcwqqdttzqzjzqqltlggwlglgwgrgfgnffgqffnlntlnlccjwjfjnfjnffqvfqfcfsslwswfwvfwfvflfhhntngnhggqbbsggchghfggcmgmsggshsmmqffjpjnngwwftwffgqqvmqqslqslqqdzqzhzbhhdzhhllnzzlmzzltlwwsmswwtswtssvqsqhssfdsdtdjdqqqrffqjffrzrppjpgjjpgpmmzbbrcbbprbpbnpbpcpsspqqfggclcpczzngznzvzlvvcwvwcwdwcddhdbdwdhwhllpjllrmmhbmbgmgmpmhpmpqmpprggvsgvsvbsbbqbmmjdjfddsnnqpnnphppsbpsbpsprpjjqhhvrhvvdhdjhdhwdhhdjjrlrbbzhbbjljhllttrccbdbffznnfmnfnvfvrvbblmltlmmlbmmdqmqnmqqmmhchvcvpccnrccqhccshchshzshschcffpwwbdbqbbjhbhmbhmmzzzcscddbsbnnpzpfzzrfrlrmmzzhshbbtjtbtzbbddrwwhchvhtvvmhvmmwssqqzrzdrdqqntnjnrjrbbgqgzgbzgbzgbzgbbqtbbbqjjgvglvlzlqlbbjwjddjtjbjffcsfsnsnpspgpnnglnngrgqgbqgqtgtfggczzmbbvqqrssdqssgrssdzzvjvccbbgcgppgwwtmwwrnwnfwwnnzmzvvvmnnvdddrmrbrtbrbrvrqqcbbgjgfjfcfttgrrjmrmrttbnnsrnsnzsnzztmtgtjgjljdjtjrtrddtbtjbtjbtthhtmmllngnhgnnhthssgffljlnjllfvlvslvsvwvcvfccgqqtsqtqggbjbtjjtjvjtvtvddttqzqczzcvvdtvthvvfrfmrrclrlflbbhhcllfbbcwwgmwmnmpmgpptnpnjpnjjbqjqjddfdfjjpzzjnnvzzwtwpwfppzhphbbmsbmsbmbqqfpfsscttfrtrzzrznrrrbgbdbtdbdjjsmjmttlbtthbttrprpjppsbsjbjcbclchlhhlttntznnzfnfgnncsncnmmdndnlnclnndqnqssbsjbbrzrtzztszzvnznqqpnpbpnpvnpnhpphvpvfvhhrvhrrpttctjcjvcvzcvcscttqptpffscfsccqhchhdcdczcnzcncnhccfrrbprpbpqppdccjhjvjmjpjmpjjvfvrrwppgjgjjdgdmgdggcpccbrrgssbsjbsjsfscfcvvcrvcrcttbtffpqphpchclccwhcwcbwccbzzlvzvffbrbrbjbwjjqvgtcfnhtjvrcwbfjdbvgtqbvmbtscwzrwdfmwtjvswgrvncmftgmppvlcwjpnpffggrmvgtfqgqmhbhpslfwdfvfmbfndrmgfhdbbtdgvnslzpdfvdttqjpcnbzsjcvrprgrhpglwfwtdcbgdsjhnqjntjnsjcgwccjnvvngfpvqwvnclcsvhmwsrccvbjnnrjspwqdvjpfnfvbsslngzpdgjrcsnqfvdlsqdhdllcndshglztgrrjnptqfvllshmhbgdszvmvqdntpgzdvhstgrppwpdtdqvzsfgqfrgmmjqcsjhvrlmnjvfjghlvwbnqcggpqtrjztfzshnqpzznvlqcmnzvrwqlcbnbpwmljpvdzhbvbgtdjlzflsvzlcqdnsgzfjlccvjclqlzdhqzzrscttjmrvjvcqzvtzqlmsssnfcfmvcgmqjjwdnhtvlqrgdvlbbrffmrpnfsmwwwbnwclrgbfnzlbqvjfqjlfvfnfrhdqstddwnwrmsdnvzwfjfgpwcrfqqzbdwwtzprvqtgvtzbttlhcdczlhvlgrbptztswftvnjmgrnbwpfwnztvqmqbznvnllgjmqrwprvwtnptlbfwbblzsblptwpdwgcvwsbmbrtqfvjsbzfvsfvpwfwbnnfcsddhsnwnvvqthjdgvzgjprtqmvhdqjqhgqppqqcpzfcwzcmrslftgrvbvdsdgfzfmvvcqzcszfwdvghdnlwwpddzdsqsdqvvrwhphbqvcbjbtnqgnqqdsqcmrllhmdvpffnqmrgfddjbrjwflshzswvjtmqgqmzvcnlctvdpjhzzlgpzgprjncrscnlmdhvdqpfllsqgstmssvlzmrtjmgwppfqjsrfmlnszdnhngzhtbbnsnvmtzpfsdcsvsvvjnfnzhrzmvlhrbslrsbgwwcvrzpgcnmjqnvgmzmlvpccrmggtzzhsdtbbcdnpdlnbztgjhttmqdhjphcrbgjtctqmgbfmflgqztztcjqvgsscrmwfbvnrnbgbjgqmwdzhwwnddwgrprhvlgftcbnwjqmcgczpbhfqcqzdbdwhmzfmgvcjdsfzdbrzjjvfrvftdblnlhpbqvdprnsjdpznbbgqpgnnjmcnsbszfwblthtwlwrdphjltclmqnbpcgngdnfpltttsrvdmhrcvlqfplqmqvslwgcbrwrmchscczrfgspwjtdqtlbddbsclrlbmhdzqdrgjfsgldfjmgcglbgjhmghntndqcbgqwmdvczbwgcctzvcrsqqctwwddfhhfhwlsrsljpnrlqtbdzprjbfrjgztwbpnfqnlftzcgrpmpcnljhscfbsqzbsgwqcgbvctnhswhrsmwjgcccdsnbscwllmpstpnrccjspnjqmtgcsgbjzpfvzjrhlvnfblqmcmgcrvnpchwhlsqsbhzhsgdvwmdcwphwccvzmmqqjrvqwphbnmddzcmggmbsqrhbcqmdlgvccbhhmhwdjhhhcwnffthmgfhpltqbhnvdqfrzjdvlppqhzfdgbzbrtfllsbvjjcgbwsbcmfrbjtvzqsntzdzprnpmfpfpgmfprlbcdqbdzjsfjbtczdpdnhlwdhmwsjtvmztbhdbbdgvrtbqsqbsnwjjhlslzcblrwlfpzqlvdvmgqhrpjmbjbntmjsjvgsmdsnctlgtnlqgfvhwqbjbrczpfzmzwgvrphfmnnhrlzwzgthzqnzzmptppzdszlcpjjvbpjbtjfrqtbnpnwsdglbbjftvngcghjlnsqwspmmfdpslsmqtpngbtvvrvbqqdsphfhvsnmhprfclnjmfrtqnlqcbmfrggbstwdbwsvtpvflvfgqltmqjpnfclbwtlwhmqrmzcrbztstgpjrdsnwpqrcnvvnnnszlrtpqjtsnbjrdcthrzrtccgcvnnlzfjlcdnzzqclvtncjbznrlpnzhvcwmrfrzpcldfmfzfpchlmddgvcfdqdhzzdtwhsfcvsthtmqgvhzdpjcgwsmrvwsnqmhdnfqdrrnmjwcpjjftfdhvwrwwtvptzfrmgffdcrhvcmccfqctswzzmlsjvdjzgjgndhmmrwvwmmtrnpgsnmtcqdbdpqjmcddcrbcfmmccnvsfhwtvfhsjfmlfttspfghpfggrffnrwjggqwggrmpzscprvdzmzhwjjcsmpsltzwgchttwpngrlptprqnjzzpbpbcvrclggtqwlcwdpjpnjrhtgqwsvhsswwqtlnglnqnvffrgmlbzthvnhrzvsvclgdmmjzrpfv

34
rust/src/day1.rs Normal file
View File

@ -0,0 +1,34 @@
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
pub fn run() {
let file = File::open("resources/day1input.txt").expect("Input file not found.");
let reader = BufReader::new(file);
let mut calorie_totals: Vec<i64> = Vec::new();
let mut current_elf_calories = 0;
for line in reader.lines() {
let calories = line.unwrap().parse::<i64>().unwrap_or(0);
println!("Input calories: {:?}", calories);
if calories == 0 {
println!("Adding to current elf total: {:?}", current_elf_calories);
calorie_totals.push(current_elf_calories);
current_elf_calories = 0;
} else {
current_elf_calories += calories;
}
}
if current_elf_calories > 0 {
println!("Adding to current elf total: {:?}", current_elf_calories);
calorie_totals.push(current_elf_calories);
}
calorie_totals.sort();
calorie_totals.reverse();
assert!(calorie_totals.len() >= 3);
println!("Day 1 Part A Answer: {}", calorie_totals[0]);
println!("Day 1 Part B Answer: {}", calorie_totals[0] + calorie_totals[1] + calorie_totals[2]);
}

50
rust/src/day2.rs Normal file
View File

@ -0,0 +1,50 @@
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
pub fn run() {
let file = File::open("resources/day2input.txt").expect("Input file not found.");
let reader = BufReader::new(file);
let mut part1_score: u32 = 0;
let mut part2_score: u32 = 0;
for line in reader.lines() {
let str = line.unwrap();
part1_score += calculate_score_part1(&str);
part2_score += calculate_score_part2(&str);
}
println!("Day 2 Part 1 Answer: {:?}", part1_score);
println!("Day 2 Part 2 Answer: {:?}", part2_score);
}
fn calculate_score_part1(game: &str) -> u32 {
return match &game[..] {
"A X" => 3 + 1,
"A Y" => 6 + 2,
"A Z" => 0 + 3,
"B X" => 0 + 1,
"B Y" => 3 + 2,
"B Z" => 6 + 3,
"C X" => 6 + 1,
"C Y" => 0 + 2,
"C Z" => 3 + 3,
_ => panic!()
};
}
fn calculate_score_part2(game: &str) -> u32 {
return match &game[..] {
"A X" => 3 + 0, // lose
"A Y" => 1 + 3, // draw
"A Z" => 2 + 6, // win
"B X" => 1 + 0, // lose
"B Y" => 2 + 3, // draw
"B Z" => 3 + 6, // win
"C X" => 2 + 0, // lose
"C Y" => 3 + 3, // draw
"C Z" => 1 + 6, // win
_ => panic!()
};
}

44
rust/src/day3.rs Normal file
View File

@ -0,0 +1,44 @@
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
pub fn run() {
let file = File::open("resources/day3input.txt").expect("Input file not found.");
let reader = BufReader::new(file);
let mut priority_sum1 = 0;
let mut priority_sum2 = 0;
let mut counter: usize = 0;
let mut group_sacks: Vec<String> = vec![String::new(), String::new(), String::new()];
for line in reader.lines() {
// Part 1
let current_line = line.unwrap();
let (compartment1, compartment2) = current_line.split_at(current_line.len() / 2);
let common_item_code = get_common_item_code(compartment1, compartment2);
priority_sum1 += get_priority(common_item_code);
// Part 2
counter += 1;
group_sacks[counter % 3] = current_line;
if counter % 3 == 0 {
let badge_item_code = get_common_item_code_part2(&group_sacks[0][..], &group_sacks[1][..], &group_sacks[2][..]);
priority_sum2 += get_priority(badge_item_code);
}
}
println!("Day 3 Answer 1: {:?}", priority_sum1);
println!("Day 3 Answer 2: {:?}", priority_sum2);
}
fn get_priority(item: char) -> usize {
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".find(item).unwrap() + 1
}
fn get_common_item_code(c1: &str, c2: &str) -> char {
c1.chars().find(|&c| c2.contains(c)).unwrap()
}
fn get_common_item_code_part2(c1: &str, c2: &str, c3: &str) -> char {
c1.chars().find(|&c| c1.contains(c) && c2.contains(c) && c3.contains(c)).unwrap()
}

60
rust/src/day4.rs Normal file
View File

@ -0,0 +1,60 @@
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use regex::Regex;
#[derive(Debug, PartialEq, Eq)]
struct ElfAssignment {
first_range_start: u8,
first_range_end: u8,
second_range_start: u8,
second_range_end: u8,
}
pub fn run() {
let file = File::open("resources/day4input.txt").expect("Input file not found.");
let reader = BufReader::new(file);
let re = Regex::new(r"^(\d{1,2})-(\d{1,2}),(\d{1,2})-(\d{1,2})$").unwrap();
let assignments: Vec<Option<ElfAssignment>> = reader
.lines()
.map(|line| {
let unwrapped_line = line.unwrap();
let cap = re.captures(unwrapped_line.as_str()).unwrap();
let groups = (cap.get(1), cap.get(2), cap.get(3), cap.get(4));
match groups {
(Some(r1), Some(r2), Some(r3), Some(r4)) => Some(ElfAssignment {
first_range_start: r1.as_str().parse::<u8>().unwrap(),
first_range_end: r2.as_str().parse::<u8>().unwrap(),
second_range_start: r3.as_str().parse::<u8>().unwrap(),
second_range_end: r4.as_str().parse::<u8>().unwrap(),
}),
_ => None,
}
})
.collect();
let mut total_overlap: u32 = 0;
let mut partial_overlap: u32 = 0;
for assignment in assignments {
let a = assignment.unwrap();
if (a.first_range_start >= a.second_range_start
&& a.first_range_end <= a.second_range_end) ||
(a.second_range_start >= a.first_range_start
&& a.second_range_end <= a.first_range_end) {
total_overlap += 1;
}
if ((a.first_range_start >= a.second_range_start && a.first_range_start <= a.second_range_end) ||
(a.first_range_end >= a.second_range_start && a.first_range_end <= a.second_range_end)) ||
((a.second_range_start >= a.first_range_start && a.second_range_start <= a.first_range_end) ||
(a.second_range_end >= a.first_range_start && a.second_range_end <= a.first_range_end)) {
partial_overlap += 1;
}
}
println!("Day 4 Answer 1: {:?}", total_overlap);
println!("Day 4 Answer 2: {:?}", partial_overlap);
}

74
rust/src/day5.rs Normal file
View File

@ -0,0 +1,74 @@
use std::collections::VecDeque;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::str;
pub fn run() {
let file = File::open("resources/day5input.txt").expect("Input file not found.");
let reader = BufReader::new(file);
let mut sorted_crates_part1: Vec<VecDeque<String>> = Vec::new();
let mut sorted_crates_part2: Vec<VecDeque<String>> = Vec::new();
let mut read_state: bool = true;
for line in reader.lines() {
let unwrapped_line = line.unwrap();
if unwrapped_line.len() == 0 {
sorted_crates_part1 = sorted_crates_part2.clone();
read_state = false;
continue;
}
if read_state {
let chunks = unwrapped_line
.as_bytes()
.chunks(4)
.map(str::from_utf8)
.collect::<Result<Vec<&str>, _>>()
.unwrap();
for n in 0..chunks.len() {
if chunks.len() > sorted_crates_part2.len() {
sorted_crates_part2.push(VecDeque::new());
}
if chunks[n].contains("[") {
sorted_crates_part2[n].push_back(chunks[n].to_string());
}
}
} else {
if unwrapped_line.contains("move") {
let args = unwrapped_line.split(" ").collect::<Vec<&str>>();
let num_crates_move = args[1].parse::<usize>().unwrap();
let source_col = args[3].parse::<usize>().unwrap();
let dest_col = args[5].parse::<usize>().unwrap();
for _ in 0..num_crates_move {
let current_crate = sorted_crates_part1[source_col - 1].pop_front().unwrap();
sorted_crates_part1[dest_col - 1].push_front(current_crate);
}
let mut crates: Vec<String> = sorted_crates_part2[source_col - 1]
.drain(0..num_crates_move)
.collect();
crates.reverse();
for c in crates {
sorted_crates_part2[dest_col - 1].push_front(c);
}
}
}
}
let answer1:Vec<String> = sorted_crates_part1
.iter()
.map(|x| x.clone().pop_front().unwrap().trim().replace("[","").replace("]",""))
.collect();
println!("Day 5 Answer 1: {:?}", answer1.join(""));
let answer2:Vec<String> = sorted_crates_part2
.iter()
.map(|x| x.clone().pop_front().unwrap().trim().replace("[","").replace("]",""))
.collect();
println!("Day 5 Answer 2: {:?}", answer2.join(""));
}

41
rust/src/day6.rs Normal file
View File

@ -0,0 +1,41 @@
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
pub fn run() {
let file = File::open("resources/day6input.txt").expect("Input file not found.");
let mut reader = BufReader::new(file);
let mut line = String::new();
let _ = reader.read_line(&mut line);
let chars: Vec<_> = line.chars().collect();
const START_OF_PACKET_SIZE: usize = 4;
const START_OF_MESSAGE_SIZE: usize = 14;
let start_of_packet: usize = find_unique_fragment_position(START_OF_PACKET_SIZE, &chars);
let start_of_message: usize = find_unique_fragment_position(START_OF_MESSAGE_SIZE, &chars);
println!("Day 6 Answer 1: {:?}", start_of_packet);
println!("Day 6 Answer 2: {:?}", start_of_message);
}
fn find_unique_fragment_position(fragment_size: usize, chars: &Vec<char>) -> usize {
let mut fragment_position: usize = 0;
for i in fragment_size..chars.len() {
let mut no_match: bool = true;
for j in 0..fragment_size {
for k in 0..fragment_size {
if j != k && chars[i - j] == chars[i - k] {
no_match = false;
}
}
}
if no_match {
fragment_position = i + 1;
break;
}
}
fragment_position
}

123
rust/src/day7.rs Normal file
View File

@ -0,0 +1,123 @@
use std::collections::{HashMap, VecDeque};
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::str;
#[derive(Debug)]
struct FsNode {
name: String,
is_dir: bool,
size: u64,
sub_items: HashMap<String, FsNode>
}
pub fn run() {
let file = File::open("resources/day7input.txt").expect("Input file not found.");
let reader = BufReader::new(file);
let mut current_dir = VecDeque::from([String::from("_")]);
let mut root_node = FsNode {
name: String::from("_"),
is_dir: true,
size: 0,
sub_items: HashMap::new()
};
let mut current_node = &mut root_node;
for line in reader.lines() {
let linex = line.unwrap();
let parts: Vec<&str> = linex.split_whitespace().collect();
if parts[0] == "$" {
match parts[1] {
"cd" => {
let dir = parts[2];
if dir == "/" {
current_dir = VecDeque::from([String::from("_")]);
current_node = &mut root_node;
} else if dir == ".." {
current_dir.pop_back();
current_node = find_node_by_path(&mut root_node,VecDeque::from(current_dir.clone())).unwrap();
} else {
current_dir.push_back(String::from(dir));
current_node = current_node.sub_items.get_mut(dir).unwrap();
}
}
"ls" => {}
_ => eprintln!("error: invalid command {:?}", parts[1])
}
} else if parts[0] == "dir" {
current_node.sub_items.insert(String::from(parts[1]),FsNode {
name: String::from(parts[1]),
is_dir: true,
size: 0,
sub_items: HashMap::new()
});
} else {
current_node.sub_items.insert(String::from(parts[1].to_string()),FsNode {
name: String::from(parts[1].to_string()),
is_dir: false,
size: parts[0].parse::<u64>().unwrap(),
sub_items: HashMap::new()
});
}
}
let mut sizes:Vec<u64> = Vec::new();
let mut sum: u64 = 0;
let mut answer2: u64 = 0;
let fs_size: u64 = 70000000;
let fs_min_space: u64 = 30000000;
let used_space = calculate_dir_sizes(&root_node, &mut sizes);
let free_space = fs_size-used_space;
println!("used space: {:?}", used_space);
println!("free space: {:?}", free_space);
sizes.sort();
for x in sizes {
if x <= 100000 {
sum += x;
}
if answer2 == 0 && free_space+x >= fs_min_space {
answer2 = x;
}
}
println!("Day 7 Answer 1: {:?}", sum);
println!("Day 7 Answer 2: {:?}", answer2);
}
fn find_node_by_path(node: &mut FsNode, mut path: VecDeque<String>) -> Option<&mut FsNode> {
let name = path.pop_front()?; // Return None if the path is empty
if path.len() == 0 && name == "_" {
return Some(node);
}
if name == "_" {
return find_node_by_path(node, path);
}
if let Some(sub_item) = node.sub_items.get_mut(name.as_str()) {
return if path.len() == 0 && sub_item.name == name && sub_item.is_dir {
Some(sub_item)
} else {
find_node_by_path(sub_item, path)
}
}
None
}
fn calculate_dir_sizes(node: &FsNode, dir_sizes: &mut Vec<u64>) -> u64 {
let mut sum: u64 = 0;
if node.sub_items.len() > 0 {
for (_, sub_node) in &node.sub_items {
if sub_node.is_dir {
let size = calculate_dir_sizes(sub_node, dir_sizes);
sum += size;
dir_sizes.push(size);
} else {
sum += sub_node.size;
}
}
}
sum
}

29
rust/src/main.rs Normal file
View File

@ -0,0 +1,29 @@
use std::env;
mod day1;
mod day2;
mod day3;
mod day4;
mod day5;
mod day6;
mod day7;
fn main() {
let args: Vec<String> = env::args().collect();
match args.len() {
2 => {
let day_to_run = &args[1];
match &day_to_run[..] {
"day1" => day1::run(),
"day2" => day2::run(),
"day3" => day3::run(),
"day4" => day4::run(),
"day5" => day5::run(),
"day6" => day6::run(),
"day7" => day7::run(),
_ => eprintln!("error: invalid day")
}
},
_ => eprintln!("Error: not enough or too many arguments.")
};
}