Moved aoc challenges from their own repos to this one

This commit is contained in:
Fabian Schmidt 2024-10-25 11:07:47 +02:00
commit ae00eb4f80
51 changed files with 11067 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

43
Cargo.lock generated Normal file
View File

@ -0,0 +1,43 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "y2015"
version = "0.1.0"
[[package]]
name = "y2016"
version = "0.1.0"
[[package]]
name = "y2017"
version = "0.1.0"
[[package]]
name = "y2018"
version = "0.1.0"
[[package]]
name = "y2019"
version = "0.1.0"
[[package]]
name = "y2020"
version = "0.1.0"
[[package]]
name = "y2021"
version = "0.1.0"
[[package]]
name = "y2022"
version = "0.1.0"
[[package]]
name = "y2023"
version = "0.1.0"
[[package]]
name = "y2024"
version = "0.1.0"

14
Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[workspace]
resolver = "2"
members = [
"y2015",
"y2016",
"y2017",
"y2018",
"y2019",
"y2020",
"y2021",
"y2022",
"y2023",
"y2024",
]

6
y2015/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2015"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2015/src/lib.rs Normal file
View File

6
y2016/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2016"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2016/src/lib.rs Normal file
View File

6
y2017/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2017"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2017/src/lib.rs Normal file
View File

6
y2018/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2018"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2018/src/lib.rs Normal file
View File

6
y2019/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2019"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2019/src/lib.rs Normal file
View File

6
y2020/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2020"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2020/src/lib.rs Normal file
View File

6
y2021/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2021"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2021/src/lib.rs Normal file
View File

6
y2022/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2022"
version = "0.1.0"
edition = "2021"
[dependencies]

2239
y2022/resources/1_input.txt Normal file

File diff suppressed because it is too large Load Diff

2500
y2022/resources/2_input.txt Normal file

File diff suppressed because it is too large Load Diff

300
y2022/resources/3_input.txt Normal file
View File

@ -0,0 +1,300 @@
rNZNWvMZZmDDmwqNdZrWTqhJMhhgzggBhzBJBchQzzJJ
pHlSVbVbFHgHBzzhQHqg
nVsqGpbbtDtTNmrmfZ
zrBMnbzBchshsttfbMRBgmJggmmCHGgDhDgNDGHL
VddZqQqdvSQMJHJGdCDCDDmH
pZWWllPQlPZQvZvwpSVlqlvtfswMRzBbntzRbzbfstsRzF
NnjjRlnWNSWWbGwccbcchfPfTvfjfTBBpvmdMjTfvB
FVzJtDDJDqTMlmlM
gVQZlFLlzHhLGShGww
rPZtvtFrFPgWjQvCBlcqMzlqQC
QGVDJJnLnVTCJBczqqTM
fNSSnmLDSVLhhhSNSLhGSGfVPjrFHwmQwtwWFRWRjWPHrwgt
SvmlrVrCvmNhSSVZVCrsgqPfbwGFwwwsflbbGb
QHffdnHDDQdMGbgqPwztdPds
DjBjWHfQDfTQWTBfpMBQLVmmmcCCcVhCBBBhhCmC
trLHFFQHTLHJQrflfCnLLHrRfRRPqSRPbPbbsRGqqGqhjj
mcMpNWVVNmNVsSbSJPcGhPRR
NpzNgwzZDVNZVWNpHJQLQHtQrZQHrBCl
JVCMfgJVrJtMBhhrfVVfhVsjvpFGFgjSSgFdSGGqjvjvqF
mHllHlHpmWlDSFqbdSTS
nmZRLzQnWVpctMVpQs
BrvRzWBPWbR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RmZTPRLPZfqqqHbDDDgFvFnvqzQ
hfZHrwwmcZRwlLfwlmrRjMJJsVjslVNBGNjpVBBG
pllpztRqBBvvGPpG
QQhhZQbVcZQTPMWWGbvvbMHM
cwgCQCLZChQwwLZVzCrzzqNCzrDqdFPF
bgcLPvvpcbdsbpSsHRTCqsRfWfsHRm
lZlQtthrnlVMmTHqqqqHSChB
rDtlzttnlSNrMtQjZVrcgGDLLddcdcpPgPGJJd
jvGbvLLQDSGlRmmSLjlDmRQggFBrMCwWdsBFWBFjdrrWrr
PpTfcPZpNTVNpHzTzzzpPJhBcwrrhFsrMdFcMCBFhgMF
JTTqdtfzfzJpqffNdTTHGtQRnmDQGGLQQlQRbblD
CQQCshCMwgQhMdjWJFBPpbjgmmWj
SNNvcGNSZSTDtGDcczJJBmzbjBJjmppbppms
cDtfDVNTGGGNNrwLLwHdqLhfLs
ngghZCChzhNjjNbbJfdh
slPPRLlBBlVRMvRllLLHvcpcdFfJjvdFpfHfcZ
RDZPZBLmPVWDVrQtnzSTmgTwmTSg

1000
y2022/resources/4_input.txt Normal file

File diff suppressed because it is too large Load Diff

512
y2022/resources/5_input.txt Normal file
View File

@ -0,0 +1,512 @@
[M] [H] [N]
[S] [W] [F] [W] [V]
[J] [J] [B] [S] [B] [F]
[L] [F] [G] [C] [L] [N] [N]
[V] [Z] [D] [P] [W] [G] [F] [Z]
[F] [D] [C] [S] [W] [M] [N] [H] [H]
[N] [N] [R] [B] [Z] [R] [T] [T] [M]
[R] [P] [W] [N] [M] [P] [R] [Q] [L]
1 2 3 4 5 6 7 8 9
move 1 from 7 to 6
move 1 from 9 to 4
move 4 from 9 to 6
move 1 from 2 to 3
move 7 from 8 to 6
move 1 from 6 to 3
move 6 from 2 to 9
move 1 from 2 to 9
move 3 from 5 to 6
move 4 from 5 to 4
move 1 from 1 to 6
move 8 from 9 to 4
move 1 from 5 to 1
move 7 from 3 to 9
move 11 from 4 to 1
move 1 from 9 to 3
move 1 from 3 to 6
move 9 from 1 to 2
move 1 from 4 to 8
move 1 from 8 to 2
move 5 from 9 to 4
move 8 from 2 to 1
move 10 from 6 to 3
move 5 from 4 to 3
move 9 from 3 to 2
move 1 from 9 to 5
move 1 from 6 to 1
move 4 from 1 to 8
move 5 from 7 to 6
move 1 from 5 to 9
move 2 from 4 to 3
move 13 from 6 to 1
move 1 from 6 to 3
move 3 from 1 to 7
move 9 from 2 to 7
move 2 from 4 to 6
move 25 from 1 to 9
move 2 from 2 to 7
move 2 from 3 to 5
move 1 from 6 to 5
move 2 from 5 to 2
move 2 from 8 to 9
move 2 from 2 to 5
move 23 from 9 to 5
move 1 from 8 to 5
move 1 from 8 to 9
move 6 from 3 to 7
move 3 from 5 to 7
move 1 from 3 to 1
move 1 from 1 to 5
move 11 from 7 to 6
move 9 from 6 to 2
move 1 from 7 to 1
move 1 from 1 to 7
move 2 from 6 to 8
move 8 from 2 to 3
move 4 from 7 to 1
move 7 from 7 to 6
move 6 from 9 to 6
move 1 from 1 to 5
move 5 from 6 to 8
move 2 from 7 to 6
move 2 from 3 to 2
move 24 from 5 to 8
move 1 from 3 to 5
move 4 from 3 to 2
move 1 from 5 to 6
move 31 from 8 to 6
move 1 from 5 to 6
move 1 from 3 to 6
move 2 from 1 to 9
move 2 from 9 to 6
move 1 from 1 to 9
move 46 from 6 to 5
move 1 from 9 to 4
move 35 from 5 to 1
move 28 from 1 to 5
move 24 from 5 to 3
move 1 from 3 to 4
move 1 from 6 to 3
move 19 from 3 to 4
move 2 from 3 to 8
move 3 from 1 to 8
move 4 from 2 to 1
move 4 from 8 to 6
move 6 from 1 to 5
move 1 from 8 to 5
move 3 from 4 to 1
move 5 from 1 to 7
move 23 from 5 to 2
move 21 from 2 to 8
move 6 from 8 to 2
move 2 from 2 to 5
move 2 from 5 to 6
move 5 from 4 to 5
move 6 from 6 to 7
move 4 from 5 to 2
move 1 from 7 to 9
move 3 from 3 to 2
move 1 from 5 to 2
move 2 from 8 to 5
move 11 from 2 to 5
move 3 from 2 to 7
move 13 from 7 to 4
move 11 from 8 to 1
move 1 from 9 to 5
move 23 from 4 to 2
move 1 from 4 to 9
move 10 from 1 to 2
move 1 from 9 to 5
move 1 from 1 to 3
move 2 from 8 to 6
move 4 from 5 to 9
move 19 from 2 to 5
move 3 from 9 to 2
move 28 from 5 to 7
move 1 from 3 to 5
move 1 from 9 to 5
move 15 from 7 to 5
move 2 from 6 to 4
move 2 from 4 to 3
move 19 from 5 to 9
move 5 from 7 to 5
move 8 from 7 to 8
move 1 from 8 to 1
move 14 from 9 to 6
move 2 from 8 to 5
move 1 from 3 to 8
move 3 from 5 to 9
move 1 from 1 to 9
move 3 from 9 to 6
move 8 from 6 to 5
move 1 from 8 to 1
move 1 from 8 to 3
move 13 from 2 to 4
move 4 from 9 to 8
move 4 from 4 to 1
move 1 from 6 to 1
move 2 from 3 to 4
move 2 from 1 to 7
move 10 from 5 to 1
move 2 from 5 to 2
move 7 from 4 to 7
move 6 from 6 to 7
move 1 from 9 to 7
move 3 from 7 to 1
move 7 from 2 to 7
move 1 from 6 to 3
move 1 from 6 to 9
move 8 from 7 to 8
move 2 from 7 to 6
move 8 from 7 to 9
move 17 from 1 to 7
move 13 from 8 to 5
move 2 from 7 to 1
move 2 from 6 to 3
move 9 from 7 to 6
move 5 from 7 to 6
move 1 from 4 to 5
move 3 from 5 to 9
move 4 from 9 to 2
move 2 from 8 to 6
move 1 from 7 to 9
move 4 from 9 to 1
move 12 from 6 to 2
move 10 from 2 to 6
move 4 from 9 to 4
move 6 from 1 to 6
move 2 from 7 to 8
move 2 from 8 to 4
move 1 from 8 to 1
move 8 from 4 to 7
move 5 from 5 to 2
move 3 from 4 to 1
move 3 from 2 to 8
move 2 from 8 to 4
move 1 from 4 to 5
move 3 from 2 to 1
move 2 from 9 to 8
move 11 from 6 to 5
move 4 from 7 to 2
move 1 from 3 to 7
move 1 from 8 to 5
move 8 from 6 to 4
move 2 from 3 to 7
move 1 from 6 to 2
move 15 from 5 to 3
move 15 from 3 to 5
move 5 from 1 to 6
move 12 from 2 to 8
move 4 from 7 to 3
move 4 from 6 to 3
move 7 from 4 to 3
move 8 from 3 to 8
move 1 from 6 to 8
move 10 from 5 to 3
move 8 from 5 to 4
move 15 from 3 to 9
move 1 from 1 to 3
move 9 from 4 to 9
move 1 from 7 to 3
move 2 from 7 to 6
move 1 from 9 to 7
move 19 from 8 to 2
move 1 from 1 to 9
move 4 from 3 to 9
move 1 from 5 to 6
move 4 from 8 to 1
move 1 from 4 to 1
move 3 from 1 to 3
move 1 from 1 to 9
move 4 from 9 to 7
move 2 from 6 to 1
move 2 from 1 to 2
move 1 from 6 to 3
move 1 from 1 to 4
move 3 from 7 to 5
move 21 from 2 to 8
move 1 from 7 to 8
move 2 from 5 to 3
move 1 from 4 to 3
move 3 from 3 to 1
move 1 from 7 to 5
move 1 from 1 to 2
move 1 from 1 to 2
move 2 from 3 to 2
move 1 from 3 to 8
move 2 from 5 to 6
move 1 from 3 to 9
move 4 from 2 to 8
move 12 from 9 to 6
move 1 from 1 to 4
move 14 from 6 to 1
move 3 from 9 to 1
move 1 from 4 to 7
move 4 from 8 to 6
move 3 from 6 to 4
move 3 from 4 to 7
move 15 from 1 to 5
move 1 from 6 to 5
move 12 from 5 to 4
move 10 from 9 to 8
move 3 from 7 to 8
move 1 from 9 to 1
move 2 from 1 to 7
move 17 from 8 to 5
move 10 from 4 to 2
move 16 from 5 to 8
move 30 from 8 to 7
move 4 from 5 to 2
move 4 from 7 to 1
move 1 from 5 to 8
move 4 from 8 to 4
move 5 from 4 to 8
move 8 from 7 to 8
move 19 from 7 to 5
move 4 from 1 to 4
move 7 from 5 to 3
move 10 from 2 to 3
move 5 from 5 to 1
move 1 from 5 to 3
move 4 from 2 to 8
move 4 from 4 to 6
move 1 from 5 to 7
move 3 from 7 to 1
move 1 from 4 to 2
move 7 from 3 to 7
move 2 from 5 to 1
move 1 from 2 to 8
move 3 from 5 to 2
move 3 from 2 to 7
move 11 from 1 to 9
move 9 from 9 to 6
move 1 from 3 to 8
move 2 from 9 to 6
move 3 from 3 to 7
move 3 from 7 to 1
move 5 from 6 to 7
move 14 from 7 to 6
move 1 from 7 to 2
move 5 from 3 to 5
move 1 from 3 to 4
move 2 from 1 to 4
move 1 from 6 to 9
move 1 from 3 to 8
move 1 from 9 to 2
move 1 from 1 to 4
move 4 from 4 to 9
move 1 from 2 to 3
move 5 from 5 to 9
move 1 from 9 to 5
move 1 from 5 to 3
move 11 from 6 to 3
move 2 from 9 to 1
move 1 from 1 to 7
move 5 from 6 to 4
move 4 from 3 to 9
move 1 from 3 to 7
move 1 from 4 to 2
move 1 from 4 to 5
move 2 from 2 to 1
move 1 from 4 to 5
move 2 from 1 to 6
move 1 from 3 to 6
move 8 from 9 to 6
move 19 from 8 to 7
move 2 from 7 to 4
move 1 from 1 to 3
move 6 from 6 to 5
move 1 from 8 to 6
move 8 from 5 to 9
move 1 from 9 to 8
move 1 from 4 to 6
move 1 from 9 to 1
move 4 from 7 to 5
move 2 from 4 to 7
move 1 from 4 to 5
move 8 from 9 to 5
move 3 from 8 to 2
move 8 from 6 to 8
move 5 from 3 to 1
move 6 from 8 to 3
move 9 from 5 to 7
move 3 from 2 to 4
move 1 from 6 to 1
move 2 from 3 to 9
move 2 from 8 to 1
move 1 from 4 to 7
move 1 from 5 to 6
move 1 from 9 to 3
move 8 from 3 to 8
move 2 from 4 to 9
move 2 from 5 to 7
move 5 from 8 to 3
move 2 from 6 to 9
move 1 from 9 to 5
move 3 from 9 to 3
move 3 from 6 to 5
move 1 from 9 to 6
move 1 from 8 to 3
move 4 from 5 to 4
move 24 from 7 to 5
move 8 from 3 to 1
move 24 from 5 to 2
move 3 from 4 to 6
move 5 from 6 to 3
move 1 from 3 to 1
move 1 from 5 to 2
move 4 from 2 to 1
move 5 from 3 to 9
move 1 from 4 to 3
move 5 from 2 to 3
move 3 from 1 to 2
move 1 from 7 to 1
move 4 from 7 to 8
move 1 from 1 to 2
move 5 from 2 to 8
move 2 from 9 to 8
move 19 from 1 to 7
move 9 from 8 to 9
move 2 from 3 to 5
move 8 from 9 to 6
move 5 from 6 to 2
move 1 from 3 to 8
move 2 from 9 to 5
move 3 from 5 to 9
move 5 from 9 to 4
move 2 from 6 to 4
move 2 from 8 to 3
move 1 from 5 to 6
move 3 from 8 to 4
move 1 from 6 to 9
move 8 from 4 to 3
move 19 from 7 to 5
move 5 from 3 to 6
move 1 from 4 to 5
move 1 from 4 to 7
move 1 from 9 to 1
move 4 from 6 to 8
move 1 from 7 to 5
move 2 from 6 to 4
move 4 from 8 to 5
move 6 from 3 to 1
move 6 from 5 to 8
move 5 from 5 to 1
move 2 from 4 to 7
move 2 from 3 to 2
move 7 from 5 to 2
move 1 from 7 to 9
move 3 from 2 to 6
move 7 from 2 to 1
move 4 from 1 to 7
move 7 from 1 to 7
move 11 from 2 to 4
move 3 from 6 to 7
move 2 from 8 to 5
move 8 from 7 to 3
move 6 from 3 to 5
move 4 from 2 to 3
move 3 from 7 to 6
move 3 from 2 to 5
move 7 from 5 to 1
move 10 from 1 to 6
move 1 from 2 to 8
move 3 from 6 to 7
move 4 from 4 to 1
move 2 from 3 to 6
move 3 from 3 to 9
move 1 from 3 to 6
move 4 from 1 to 4
move 3 from 9 to 6
move 2 from 4 to 1
move 9 from 4 to 7
move 11 from 7 to 4
move 6 from 1 to 6
move 6 from 4 to 7
move 5 from 4 to 7
move 4 from 8 to 1
move 1 from 8 to 6
move 1 from 9 to 7
move 4 from 6 to 4
move 5 from 5 to 4
move 5 from 5 to 9
move 5 from 1 to 6
move 1 from 5 to 6
move 4 from 9 to 7
move 1 from 9 to 8
move 7 from 7 to 1
move 1 from 7 to 8
move 4 from 1 to 5
move 5 from 4 to 1
move 1 from 4 to 8
move 6 from 1 to 2
move 11 from 6 to 8
move 2 from 8 to 9
move 1 from 5 to 9
move 6 from 2 to 8
move 1 from 1 to 2
move 2 from 7 to 8
move 1 from 9 to 2
move 2 from 2 to 8
move 1 from 7 to 8
move 10 from 8 to 3
move 3 from 5 to 9
move 4 from 8 to 5
move 4 from 8 to 2
move 7 from 7 to 8
move 2 from 5 to 9
move 1 from 5 to 1
move 2 from 7 to 8
move 5 from 3 to 5
move 1 from 1 to 3
move 1 from 1 to 6
move 1 from 2 to 4
move 7 from 6 to 4
move 2 from 2 to 3
move 3 from 8 to 4
move 2 from 3 to 1
move 3 from 5 to 6
move 3 from 6 to 8
move 1 from 1 to 9
move 3 from 3 to 1
move 8 from 8 to 1
move 1 from 2 to 9
move 1 from 6 to 2
move 3 from 5 to 1
move 1 from 8 to 3
move 3 from 4 to 1
move 4 from 8 to 9
move 1 from 7 to 1
move 7 from 1 to 6
move 8 from 9 to 6
move 1 from 8 to 9
move 4 from 9 to 8
move 15 from 6 to 5
move 3 from 1 to 6
move 2 from 1 to 2
move 1 from 2 to 7
move 1 from 9 to 6
move 3 from 8 to 1
move 1 from 4 to 9
move 11 from 5 to 9
move 1 from 7 to 1
move 1 from 2 to 3
move 2 from 3 to 4
move 6 from 1 to 7
move 7 from 4 to 5
move 2 from 6 to 7
move 1 from 4 to 5
move 2 from 4 to 1
move 13 from 9 to 1
move 2 from 3 to 2
move 1 from 3 to 7
move 2 from 4 to 1
move 4 from 6 to 9
move 1 from 8 to 4
move 4 from 6 to 8
move 1 from 4 to 9
move 9 from 1 to 6
move 8 from 6 to 9
move 4 from 5 to 3
move 1 from 8 to 4

View File

@ -0,0 +1 @@
srjsssgppnssqzszmzjmjdmmqwqcwqccslsjswjssgbsgsnggqtqnnjznndtndnhddfldfdsfswsjsjjptjpttlwlccpnpgngcncnscncsnnwrwmwggsgdgssvbsstzsstqqrjqqlsqlsqscschhclhccznzcnnzzqppjbpjjqzzbwbqqzdqdjjqtjtbtgtqgtgdgwwsjjbwjjzssrsvsttgqtgglgplgpllcrcncssbrbgrbrllsqlsltthshrrnddwzdzdbbrppdvdqvvpvdvdsslbbmnbnjjrdrnntzzftzftttrsshpspvvrzzqzwzhzszbzjjwqwvqqglgflfwfrfprpddfvdffhzztwtppwwwztzsznzmnnbvbbtqqdhqdqdfffnjnmnlmljmlmnlnddzbbdgdqdnqqtjjtnthttvwwtrwwwgffqcfchfcfwcczhhgjhghpgpwgwffhghzghhtftntnnmlnmlmddqbbfwbfwbwvvfssrggptpltpllbcbzczzlccjgcgvcczjzvvvdtvdvqdqwdqdvdjvddjfdjjqmmfgfsftfzfwzwzfftmfmmqdqccjqcqwwflwlccpssvzzzbnbjnbjjgtgpttbwbrbwrwvrrwccgrgrvvpjvvznvvhddtdldpldppmlplltdllhqhpqhqqbpptgpgjgqjgjffvfdvdttsrsllhzlzrrdrnrjrddqbbjrrvrsstgsttjqjhjbhhnmndmmnrmnnrggmtgmmhshjjfqjjtqtstpstppggtzzrsrwwqffvzvzvqqggqsqtstszttpvtvvvddcncvncvchhnsnpsnnlmnnmqnqjjfwfccmwmbwbswbswwghhzrrptptbbjbtjjgdjgjrgrwgwlglblbnlnbbwnnpbnbmbtmtvvhjjlwlhhszslldwlwdllhjhghqghhqpplhhtjhhnhqhlhjhmmlhlmmrpptvvcczfcccwgcccpgpspdpccfhchffbjbzzwppfbbstbtltpllcssnnctnnqcqhhclhccvlvlffnjjwbwfbfttwvvdvnnnsrstrtmtfthtzzcvzvhzzpmpfpmmmwggdbdqdbbjnbbdqbbrnnnprrwbbcwbbpjjprjjzzvwwvrrthhqvhvnhhzmzszrszsjssclcjjbhjbhjbhjbjhhzbbzttnrnssrbrjbrjjmsmffdlflfzfbzzmtztdthdhldhlddnccgbbmtbbsbzsbzzcsszpzfffprfpfzfrzzhvhffsmmqtjwgjbzhnmrslrmgfjpqcllcgsjdhrshqtlgmqqtfmswfzwtnrswtzdjzclcfmltqgdhcsgvzrdltgfbtqclpppvbqnbqmlhmdbsjbwbdllzpnrwfhmnlgvdwsdjsznnhqzhwntjvcpzdrfwmwwdrttdvzspmbmqggmlmsvwgcjgpvcmplqwfjgpghnfpbctnfhcgngcbdmzhlpcnjpmczzsgfgrdftrzgvmmpdmgcrpcdrjsgczpfjnwpdjpntdngdjwctvcbsjmfwvtsrlhvpswppmfwrwzsbsgbjvljzqjjldmnqnmwsmqnmhmqhhttppbpqlvdcvdbhmbnjzztjrdjdzlvmbdrghtftwdpcwwblsjbgnzwtpztmtmnrpsvzfzncqmrvhcbqcvqvnlngdcllrqlbhjttnmjmhfhdzmjmplcfdqpmwblzsnmpczwcnggcwdvgnjcrrtmpwwqdqpvtbzpdbfnbfcfllntqjlslcsznjvzvsbntrtzwhcbtdmbmwttvhdvdtvrcmprcrrjlgsqddrsmwsrbtbpjrmlbrnsdrjfhjnqjtgjmhzjbjnprvmhtjcdbztwqmrlfflfmcslshtwmwhgvbdslgjhzjlglhllsdphlzngjfwfrlwpnqfhghnqhzhgrszbcwjvlrtmshntszsqplvfbccjwctgtfmqgqjdlgdbwhgvctqtcgfdwvqdwqzddmsbrpftzpqztgzbnplvhftmgpdthnrdhqbltbrmhpcqsfccmqzwmrbnbgbjspslwpjhdqspssqdtnssmjmvzwwfstgzzjrmfczdlznwqpdhbsjqddvffcgfhfdqdrlwcsgcsszdtpqbbsthpwbhdfzmgmcdggfcwcmzfjnfbzbccjhvwhbwfslnqnrwhgrwtlnmrmncnjtbjbdlmqsczppgbcmsdrwlrpjbgrmnhqqfhhsdhmdmpvvpjrnzsvzctmqhpzcvcjfgtlfvqvnvlnprmgrsvrrvtjfndqfsvqdsfbcwlbglmfhfhcfgqdfmclnzhdtppgzzsqgjqncqrbdhlhdjqwjpmbdnfmgdgwbwmnlngnmrhcgqwzvmbjzdvsspjwwdtpnvpftdlqlzfgtscfczsvbrtrqqpgqlvmrtddqplbzsswbgpdzpqfvqpqbndblghmdhmnctdnjbgglmrlvmrmsfgntfdwvqcvvlvbcnwrctvjqhmnsjqccwltbfqpqpmwsfvmnnfqmlmlcchqcdtbvqwcpptvfwrwtbdrlsgnwpmjgnwlprzqjlwqmtmjglbrzlgfbsghwqdmwhrcmfwdmzmflsbngtgndftdpzsqvgqdsfdhplmfcmwpbtvcdmpghmfwqjvhdhfpmbrqpvnbhlftgdtprlztrgnlcldfpjqjqdfrvqtcnzrtjcgzgsslzghlnfhwwjwzdsmpsczclrfmnqjvfmvsqpntsnnnlrfswqtrppzhqgjzlzvrrbhhfhchhvgztpgctcsgssvttszsrdwzwrbmwmspgqhmmfnzqqdbmnbltdmrsvqgddltwczbbjcmplncspgqgmzrndhttsrbvqbpbvhshfqrpqgmmdbhmmtccjcmntmpqhrvhnfnlqqbctsnfzjbphhqwmztgbhqqlbctbsfcszbggzrlcdhwddtjgtqhppzgjsqcddwjsngjrcdflmgwgfnzhjtcwgbqvpwmpgcpdwvqgswwfzcnjgmdpffmqczmsqgpthpmsjlwnrcbzrfshvwftzllwrmfccmlpjnmpjdfpcvjgjpznllmqjwpcflgqgdljtbbjvjlvhhmtvzfnjfnnwrvtlfdbhqphrjghtmlsrplqscsnvjvqdslsbsfzzrjfmchplzgjgdqvzhfphvsjfvnqlgmjfzhrdlmmvfntnzdvrnwqshsmtjnqmwzgpbbzszrsqcvlzjwnmgjhmfqrbvgmfqpswctmvpfcghvdqgstglmzvpfhzfzvhqqdmvrvrttlpwwhqgddzqlrvvdffqtznvlfgjhhmvbmtzjqnnhqzrtbzpqcwpngrdcndcgzwhzgtfwbmwbrpvvczczhwcqwsqzqbqvqftcswtcbzdbpccjhtwbpnwlwwwqwscptlwshrdbmmdcgrmpnnwgjwzszwwdwctfspbfqvdjqtrflshrqlbfgpnrmbszwjpcdzbggphgplcgvwljprzmtncsvfwqchttndhpnzmtdvtjqtcsddtqvcmztmjgwqvjhflrjjtnvfpjrnlvzvwvrpbhrzslmrqqzqhnzqnvtqppmncddphbwwsjczmphsrlltzndtqjgdlqgpnlfcvwntstmrgcrjzmmllpwldnwmwzpvzctmhszspcvtgnqthszzsmtdnzwtfddfctpjhscbqgwfpqmzpvqrzvtbrdjzrqprdgbpmzzfbgqcvcdtsfrffcpqwtvdwvtcqlcsdrzntgrhrspznndslmnvptlphpdqgbblfhmgbpmmfwqzlhvzshhpzgfjldqclngbcbrmmnqqvqmwdnjsglsggqfgjldqfbsqgtrwmpdffqlcwwlfhlpqfgwtssnjwzhgvtwqzmhmgwzwmcggmpmrzqrcsmflqsrbnzvdmjcdbnscstqrqhvddsbjpzwsvzswqhcqmgzlvfcnzjrrffzphmrvdbhqbrwpsfqvfqwhqhcgfvfsfttzcdsrjgjwcgvhllszmplmvgczqsbfldnbvrnqccbprjjdwhmqpdjjrnfdlhzdvlfmrldjlqclbjrrtjfsflphzdcdpfpr

1074
y2022/resources/7_input.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
102200120221123133322123221134224301040024344534431245323303212210030001244234132301200020310012011
210101220131232022104432220132221131234351145114524135253112332342312410211104233102330122201111010
002220112233222031400442434031011023425412431121343221233533224144034042201244323431032200232101012
200202231012120110032413231132224255311432523511252253221451514335154032332342133133133321000002220
021023013300203310410132030422351131224513211322513324212421215535543510221102312443303330132321201
001000330003220124130413311435314333354422521213321212242324211253514231442434324114124112323213001
100102012222213131014440444431424445231224532554231331431314545111552115245032312032141101232330001
112030330123430022102413341315541514452151222122465233323221252533543352235542444442034423330030001
212220032321414402242244545523153553234542346353663246322653331223132222122541241230343040131203330
223102313102121144404243154422531311366656226224656422433224222614245141545331252010213304333030112
100313021142341022443315312525141153654243246335365444433433242564631411555354514413134142003013020
122100230243123431213132113351516264232625236426434255344356324456666353241325433254422420014331213
011210132432422344542335312531565433356653464522633446652252525265444443411223445354243041444410112
012133444121412434113141455535326243636244246332533653666555655543624564414533423445222430103212001
113304142301420414252411342353422662436622352326554363565223456253643362524444125221430220323313003
001122120140431312155253523546562455546532337333734675677655555353242655326323332554242403211400130
220142433201434435251233346626262436553645465666436354364343766652325424552325555415524344132040133
320312104024221552154216633626342464343336367474637464363774565432432226533664243124324341232022302
021242423424424124554553554665252264547377663445576756547536647776752524253664541521223254440241211
224110204241522415245443625466664753754755446565575545765564376455744544623665244525325432143401021
123432321343113542235654656235537756354436347355473343434764344347577566652236626435125155304243232
111402302541335421642222546635377463553444734465334736537344446664655457236454264531411125250241041
404243032431142122562535544633766456373766657455756567565566363544655474453243534523435114313430121
324421025342212256655666646657743477746456644785547574464646443645543543772542656432522353312430232
001414034352355125223334566537547773645784645548858657864456755667733554477463225644645134533303241
120200313513214346523222343534564536445747674784578474688866757844677344466452533232643351552212344
140004115211334466633442746534576475745584467454447866848876885674465363455562246436243422245134202
240311554155422565345224744376657664864784867858785584464568776546846456646764446265456535141322412
120433124512123235464464474374555586847475678876745784486754865847644364763436544532466611335224012
203035433353423566534634356646374787666466647567896557758654565578474554555573556364424245252252414
303212242114562363256553377464644876787465779966759998978596466765544677666544346655666361143511511
321435212244453243635446333355488787767685799988798856567786944567778876663776374463333531123254443
321335455154254226677665466555765485559588886969685888679596565587486648633737637533532565154423142
212254414122253423565743374454588455585686588899875787766987689775655787747564557655455342253355324
421422342453446266357576668665558765689955566967658699885985767778745455574334765743326436551224544
322421225225343446747576654567854856855589798985878786666568869665488456645344737545652626331455433
222122521256633657563766766555546555855966796578977676986675868875545864778446455474333436233525114
023254314555364655763674546647685985696665859897979798699895787776754674648744636743425352264545211
225135212533322677553356845558877878985878796877869899696786965865955448755574744366722233654152541
351532143355433244443675556588657988776586966876989779969768796786657855888885536646664425523132442
124515553625366556335768876868569859658686789999979886979876785986595667566478737355543355336355531
014314156442535433773675645776556955878889968787696997666987675979557987658877644756564444225521113
242252525623363454375455757457997976769999667777997788867869896685899586858856533746453433352234235
023124456566552443376536887866777785856779768999879768967669699896775996557775364533554542434243532
223212425265546436677586688558777558698896789789999779996888676857756888467864635543336466465124415
515252333623442437447768566445979556986878966888877987877868886887578986858454675534554625552123132
412113362546222337753387655589789688778666867977779997787677869678997869748548765747344532346625545
352443343534562353437684565877667578896989969879787778999697976996568955766447746674356435354542353
244532256342454775576468664478555979788879687779998799789879799769756679848467875743746256555435243
252415145222625746477544486589996556968998687777998898799777866997997988457845575665744522252455434
121252366666324777366354648567898987766689978889888798878866677775798597554668636346634424246241143
542231223323635647757665768465587586899676779988899797877986698665695688447754433537676242553421153
315225522426633565736564558659658677797979699989788878799876868665785765575768537473673552525343311
341442555252446433735587744487688988999678768989777798879679969679999999468485664567446334355524445
211522352343562564765585578469688867869667998977797998798888877686996875745458474656532245544211451
443143434636652677635354556867668988666786999778788779898699967757566589857774775447532524634131213
354152534456625467746446747678795956888788886888778789977879678658675695565654557453375652556521414
332344344563334636745465546446885667986686979788897779997969896886588854565468765446733444424331344
431135355245345747455456787578659995678989886897697777968798896878886857486556576564733534432142551
433233316556526255633378546755489975567978866786699677769889695967977758448667443757622555435434414
314545435553452545376335754568779985959566976978878677678777868796558868674848566345422265562252423
145542533645544657663644857446856777777978979788686887887779999586699644786474643375746262664243444
241353431554264566677765464654485867995877868699696987786976958699567574887566645746345422454143441
423135115666355654375646368544778695956967666977986977697899789689766567785666675773435325262524551
121242511146354267445534487686788465757658866587778978657999996978874566576767474455232556422235215
123455555234455453537357738876787679765895779577559859577987565678475674467346366664333243354411434
113111232245536443357354765765648848855685798699976566767695895956674785776437653532662646355133522
034245121152464645264454454458567747667859589888698959868659799684876674563464553323545665335113414
321542511513646356466656747484676777865877857765878865985699957645675457654757775562546453441355233
001025225344365554343664374675774455757659659777596798967769555466788558746776567242245663132335222
240224423154453466635367766446776854675446678578756687675776756657745777743437435645463423354213440
143321412151126564642553643433487476454478865659797785666686467645568676646646473662544534334515212
300115342534164343654435573634646548844886487647548855785866576457458436355575564454635251454435213
331024513222536555236525434736356587874465687545468546688486445577473343474477264254545135125421102
243234315251353456432325545375553348757866746774448555444556677858854465433745435663355535522444302
222242353531424355464446643456665437556444758477468585685746584584647636633743354324232532231543430
232321431115224556244223336543364633735554888856857755655758564767754545375346544656511252413530322
443102445423141155626432534467654356676376855848756755575858656334754446333542345522445552422021421
122144244122552411433244654557543734547646557548877564645335454433576334464425263323112222114003403
241010140424452455226655236255746455563753554474656337467375374536454766656446525662141142521030310
003123001114142554125526633642767765437644573343536573563636666365667652335363363321131215341024444
122433034123242324526252334224465375535435776677656444337356333564364442536426546535413351434442403
012032130443313512142334334232632463533753446736437357543755653745644654244446442551351434201043201
123432104214215425255545532345225366546356457753453435764534444432222425353255324435341532212441100
122231022230433534232123222566354453436645454476533354465573437634666223324445223122344241413403220
112110012033231221323443134255336365322364443757433347343746254333526424644325111313532214100130002
000013103142014413122533343334343335263464325254335443366245355455625252566552214225151144323332120
313300010430420353244125522132426466255355444624632264532642466635524442242431233341320143344442332
232120313033343242144144352243623263245464423245465622443446436362336321555545313154201324441110203
103011001110214411345544335425116266333555324456646522333423435432424344435555224341402040022203300
222303333302140132001312342553322343232445543335233323222554662464411343213214525220341304342100233
231113123213311002102322233322235413333535624634455543444366422633445212132343132400040434221232230
103320010113214231110254523114243444121544236632534455264632443421454553331443122123000343120020102
213132131011312123433303212223431254241531411266432544214153545355412323324230143343304101121201113
110210203103022203344123142431553332324551324112424531442554431321223224324223004404030411100120120
120111302211224404102444220332233212524433322312343524235355245433352212141024210012324123323312101
212220310221122231114014131431245134434533152114425513144445231545452244244103411331010011212031200
211120022231100333330313111120423213143252332533514251453113433321354142442041432101120010313310122
111210213300233203233222413444104203323252533215253431341253534525013210232012413312211122123302112

2000
y2022/resources/9_input.txt Normal file

File diff suppressed because it is too large Load Diff

20
y2022/src/bin/d1.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d1;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/1_input.txt")).unwrap();
println!("{}", d1::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/1_input.txt")).unwrap();
println!("{}", d1::process_part2(&content));
}

20
y2022/src/bin/d2.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d2::{process_part1, process_part2};
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/2_input.txt")).unwrap();
println!("{}", process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/2_input.txt")).unwrap();
println!("{}", process_part2(&content));
}

20
y2022/src/bin/d3.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d3;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/3_input.txt")).unwrap();
println!("{}", d3::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/3_input.txt")).unwrap();
println!("{}", d3::process_part2(&content));
}

20
y2022/src/bin/d4.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d4;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/4_input.txt")).unwrap();
println!("{}", d4::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/4_input.txt")).unwrap();
println!("{}", d4::process_part2(&content));
}

20
y2022/src/bin/d5.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d5;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/5_input.txt")).unwrap();
println!("{}", d5::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/5_input.txt")).unwrap();
println!("{}", d5::process_part2(&content));
}

20
y2022/src/bin/d6.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d6;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/6_input.txt")).unwrap();
println!("{}", d6::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/6_input.txt")).unwrap();
println!("{}", d6::process_part2(&content));
}

20
y2022/src/bin/d7.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d7;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/7_input.txt")).unwrap();
println!("{}", d7::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/7_input.txt")).unwrap();
println!("{}", d7::process_part2(&content));
}

20
y2022/src/bin/d8.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d8;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/8_input.txt")).unwrap();
println!("{}", d8::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/8_input.txt")).unwrap();
println!("{}", d8::process_part2(&content));
}

20
y2022/src/bin/d9.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2022::days::d9;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/9_input.txt")).unwrap();
println!("{}", d9::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/9_input.txt")).unwrap();
println!("{}", d9::process_part2(&content));
}

49
y2022/src/days/d1.rs Normal file
View File

@ -0,0 +1,49 @@
pub fn process_part1(input: &str) -> i32 {
let mut vector: Vec<i32> = input
.split("\n\n")
.map(|lines| lines.lines().map(|line| line.parse::<i32>().unwrap()).sum())
.collect();
vector.sort_by(|a, b| b.cmp(a));
vector[0]
}
pub fn process_part2(input: &str) -> i32 {
let mut vector: Vec<i32> = input
.split("\n\n")
.map(|lines| lines.lines().map(|line| line.parse::<i32>().unwrap()).sum())
.collect();
vector.sort_by(|a, b| b.cmp(a));
vector.iter().take(3).sum()
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "1000
2000
3000
4000
5000
6000
7000
8000
9000
10000";
#[test]
fn it_works() {
let result = process_part1(INPUT);
assert_eq!(result, 24000);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 45000);
}
}

106
y2022/src/days/d2.rs Normal file
View File

@ -0,0 +1,106 @@
pub fn process_part1(input: &str) -> i32 {
let result = input
.lines()
.map(|round| {
let (opponent_move, my_move) = round.split_once(" ").unwrap();
get_points(opponent_move, my_move)
})
.sum();
result
}
fn get_points(opponent_move: &str, my_move: &str) -> i32 {
let mut round_score = 0;
match my_move {
"X" => {
round_score += 1;
match opponent_move {
"C" => round_score += 6,
"A" => round_score += 3,
_ => (),
}
}
"Y" => {
round_score += 2;
match opponent_move {
"A" => round_score += 6,
"B" => round_score += 3,
_ => (),
}
}
"Z" => {
round_score += 3;
match opponent_move {
"B" => round_score += 6,
"C" => round_score += 3,
_ => (),
}
}
_ => panic!("Shouldn't happen"),
}
round_score
}
pub fn process_part2(input: &str) -> i32 {
let result = input
.lines()
.map(|round| {
let (opponent_move, round_result) = round.split_once(" ").unwrap();
get_points_fixed(opponent_move, round_result)
})
.sum();
result
}
fn get_points_fixed(opponent_move: &str, round_result: &str) -> i32 {
let mut round_score = 0;
match round_result {
"X" => match opponent_move {
"A" => round_score += 3,
"B" => round_score += 1,
"C" => round_score += 2,
_ => (),
},
"Y" => {
round_score += 3;
match opponent_move {
"A" => round_score += 1,
"B" => round_score += 2,
"C" => round_score += 3,
_ => (),
}
}
"Z" => {
round_score += 6;
match opponent_move {
"A" => round_score += 2,
"B" => round_score += 3,
"C" => round_score += 1,
_ => (),
}
}
_ => panic!("Shouldn't happen"),
}
round_score
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "A Y
B X
C Z";
#[test]
fn it_works() {
let result = process_part1(INPUT);
assert_eq!(result, 15);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 12);
}
}

68
y2022/src/days/d3.rs Normal file
View File

@ -0,0 +1,68 @@
fn char_to_prio(char: char) -> i32 {
let ascii = char as i32;
match ascii {
65..=90 => ascii - 38,
97..=122 => ascii - 96,
_ => panic!("Shouldn't happen"),
}
}
pub fn process_part1(input: &str) -> i32 {
input
.lines()
.map(|line| {
let (first, second) = line.split_at(line.len() / 2);
let mut prio = 0;
for first_char in first.chars() {
let found_char = second
.chars()
.find(|second_char| second_char.eq(&first_char));
if let Some(char) = found_char {
prio = char_to_prio(char);
break;
}
}
prio
})
.sum()
}
pub fn process_part2(input: &str) -> i32 {
let mut lines = input.lines();
let mut result = 0;
while let Some(elf_1) = lines.next() {
let elf_2 = lines.next().unwrap();
let elf_3 = lines.next().unwrap();
for elf_1_char in elf_1.chars() {
if elf_2.contains(elf_1_char) && elf_3.contains(elf_1_char) {
result += char_to_prio(elf_1_char);
break;
}
}
}
result
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw";
#[test]
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 157);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 70);
}
}

79
y2022/src/days/d4.rs Normal file
View File

@ -0,0 +1,79 @@
pub fn process_part1(input: &str) -> i32 {
let result = input
.lines()
.map(|line| {
let (elf1, elf2) = line.split_once(",").unwrap();
let elf1 = elf1
.split_once("-")
.map(|(start, end)| start.parse::<i32>().unwrap()..=end.parse::<i32>().unwrap())
.unwrap();
let elf2 = elf2
.split_once("-")
.map(|(start, end)| start.parse::<i32>().unwrap()..=end.parse::<i32>().unwrap())
.unwrap();
if (elf1.contains(elf2.start()) && elf1.contains(elf2.end()))
|| (elf2.contains(elf1.start()) && elf2.contains(elf1.end()))
{
return 1;
}
0
})
.sum();
result
}
pub fn process_part2(input: &str) -> i32 {
let result = input
.lines()
.map(|line| {
let (elf1, elf2) = line.split_once(",").unwrap();
let elf1 = elf1
.split_once("-")
.map(|(start, end)| start.parse::<i32>().unwrap()..=end.parse::<i32>().unwrap())
.unwrap();
let elf2 = elf2
.split_once("-")
.map(|(start, end)| start.parse::<i32>().unwrap()..=end.parse::<i32>().unwrap())
.unwrap();
if elf1.contains(elf2.start())
|| elf1.contains(elf2.end())
|| elf2.contains(elf1.start())
|| elf2.contains(elf1.end())
{
return 1;
}
0
})
.sum();
result
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8";
#[test]
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 2);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 4);
}
}

110
y2022/src/days/d5.rs Normal file
View File

@ -0,0 +1,110 @@
fn is_string_numeric(str: &str) -> bool {
for c in str.chars() {
if !c.is_numeric() {
return false;
}
}
true
}
fn parse_move(crane_move: &str) -> (usize, usize, usize) {
let mut crane_move = crane_move
.split(" ")
.filter(|s| is_string_numeric(s))
.map(|m| m.parse::<usize>().unwrap());
(
crane_move.next().unwrap(),
crane_move.next().unwrap() - 1,
crane_move.next().unwrap() - 1,
)
}
fn parse_moves(crane_moves: &str) -> Vec<(usize, usize, usize)> {
crane_moves.lines().map(parse_move).collect()
}
fn parse_stacks(stacks: &str) -> Vec<String> {
let mut lines: Vec<&str> = stacks.lines().collect();
let mut last_line = lines.pop().unwrap().trim().to_string();
let num_stacks = last_line.pop().unwrap().to_digit(10).unwrap();
let mut parsed_stacks = vec!["".to_string(); num_stacks as usize];
for line in lines {
for (idx, c) in line.chars().skip(1).step_by(4).enumerate() {
if c.is_alphabetic() {
parsed_stacks[idx].insert(0, c);
}
}
}
parsed_stacks
}
pub fn process_part1(input: &str) -> String {
let (stacks, crane_moves) = input.split_once("\n\n").unwrap();
let mut stacks = parse_stacks(stacks);
let crane_moves = parse_moves(crane_moves);
for (iterations, from, to) in crane_moves {
for _i in 0..iterations {
let popped = stacks[from].pop().unwrap();
stacks[to].push(popped);
}
}
let mut result = "".to_string();
for mut stack in stacks {
result.push(stack.pop().unwrap());
}
result
}
pub fn process_part2(input: &str) -> String {
let (stacks, crane_moves) = input.split_once("\n\n").unwrap();
let mut stacks = parse_stacks(stacks);
let crane_moves = parse_moves(crane_moves);
for (iterations, from, to) in crane_moves {
let from_len = stacks[from].len();
let from_old = stacks[from].clone();
let (new_from, popped) = from_old.split_at(from_len - iterations);
stacks[from] = new_from.to_string();
stacks[to].push_str(popped);
}
let mut result = "".to_string();
for mut stack in stacks {
result.push(stack.pop().unwrap());
}
result
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = " [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";
#[test]
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, "CMZ");
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, "MCD");
}
}

68
y2022/src/days/d6.rs Normal file
View File

@ -0,0 +1,68 @@
pub fn process_part1(input: &str) -> i32 {
let mut marker = "".to_string();
for (idx, c) in input.chars().enumerate() {
if marker.len() == 4 {
return (idx).try_into().unwrap();
}
if let Some(c_pos) = marker.find(c) {
let (_, new_marker) = marker.split_at(c_pos + 1);
marker = new_marker.to_string();
}
marker.push(c);
}
0
}
pub fn process_part2(input: &str) -> i32 {
let mut marker = "".to_string();
for (idx, c) in input.chars().enumerate() {
if marker.len() == 14 {
return (idx).try_into().unwrap();
}
if let Some(c_pos) = marker.find(c) {
let (_, new_marker) = marker.split_at(c_pos + 1);
marker = new_marker.to_string();
}
marker.push(c);
}
0
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT1: &str = "mjqjpqmgbljsphdztnvjfqwrcgsmlb";
const INPUT2: &str = "bvwbjplbgvbhsrlpgdmjqwftvncz";
const INPUT3: &str = "nppdvjthqldpwncqszvftbrmjlhg";
const INPUT4: &str = "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg";
const INPUT5: &str = "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw";
#[test]
fn part1() {
let result = process_part1(INPUT1);
assert_eq!(result, 7);
let result = process_part1(INPUT2);
assert_eq!(result, 5);
let result = process_part1(INPUT3);
assert_eq!(result, 6);
let result = process_part1(INPUT4);
assert_eq!(result, 10);
let result = process_part1(INPUT5);
assert_eq!(result, 11);
}
#[test]
fn part2() {
let result = process_part2(INPUT1);
assert_eq!(result, 19);
let result = process_part2(INPUT2);
assert_eq!(result, 23);
let result = process_part2(INPUT3);
assert_eq!(result, 23);
let result = process_part2(INPUT4);
assert_eq!(result, 29);
let result = process_part2(INPUT5);
assert_eq!(result, 26);
}
}

200
y2022/src/days/d7.rs Normal file
View File

@ -0,0 +1,200 @@
use std::collections::HashMap;
#[derive(Clone, Debug)]
struct Directory {
size: i64,
children: Vec<String>,
}
fn get_size(dir: Directory, directories: HashMap<String, Directory>) -> i64 {
let mut size = dir.size;
if !dir.children.is_empty() {
size += dir
.children
.iter()
.map(|child_name| {
if let Some((_dir_name, child_dir)) = directories.get_key_value(child_name) {
return get_size(child_dir.clone(), directories.clone());
}
0
})
.sum::<i64>();
}
size
}
pub fn process_part1(input: &str) -> i64 {
let mut pwd = String::from("");
let mut directories: HashMap<String, Directory> = HashMap::new();
let lines: Vec<Vec<&str>> = input
.lines()
.map(|line| line.split_whitespace().collect::<Vec<&str>>())
.collect();
for line in lines {
if line[0] == "$" {
if line[1] == "cd" {
let arg = line[2].to_string();
match arg.as_str() {
"/" => pwd = arg,
".." => match pwd.as_str() {
"/" => println!("Already at root"),
_ => pwd.truncate(pwd.rfind("/").unwrap()),
},
_ => match pwd.as_str() {
"/" => pwd.push_str(&arg),
_ => pwd.push_str(&("/".to_owned() + &arg)),
},
}
if !directories.contains_key(&pwd) {
directories.insert(
pwd.clone(),
Directory {
size: 0,
children: vec![],
},
);
}
}
} else if line[0] == "dir" {
if let Some((dir_name, dir)) = directories.get_key_value(&pwd) {
let mut new_children = dir.children.clone();
let mut new_child = "/".to_owned() + line[1];
if pwd != *"/" {
new_child.insert_str(0, &pwd);
}
new_children.push(new_child);
let new_dir = Directory {
size: dir.size,
children: new_children,
};
directories.insert(dir_name.to_string(), new_dir);
}
} else if line[0] != "dir" {
if let Some((dir_name, dir)) = directories.get_key_value(&pwd) {
let new_dir = Directory {
size: dir.size + line[0].parse::<i64>().unwrap(),
children: dir.children.clone(),
};
directories.insert(dir_name.to_string(), new_dir);
}
}
}
let sizes = directories
.values()
.map(|directory| get_size(directory.clone(), directories.clone()));
sizes.filter(|size| size <= &100000).sum()
}
pub fn process_part2(input: &str) -> i64 {
const TOTAL: i64 = 70000000;
const MIN_UNUSED: i64 = 30000000;
let mut pwd = String::from("");
let mut directories: HashMap<String, Directory> = HashMap::new();
let lines: Vec<Vec<&str>> = input
.lines()
.map(|line| line.split_whitespace().collect::<Vec<&str>>())
.collect();
for line in lines {
if line[0] == "$" {
if line[1] == "cd" {
let arg = line[2].to_string();
match arg.as_str() {
"/" => pwd = arg,
".." => match pwd.as_str() {
"/" => println!("Already at root"),
_ => pwd.truncate(pwd.rfind("/").unwrap()),
},
_ => match pwd.as_str() {
"/" => pwd.push_str(&arg),
_ => pwd.push_str(&("/".to_owned() + &arg)),
},
}
if !directories.contains_key(&pwd) {
directories.insert(
pwd.clone(),
Directory {
size: 0,
children: vec![],
},
);
}
}
} else if line[0] == "dir" {
if let Some((dir_name, dir)) = directories.get_key_value(&pwd) {
let mut new_children = dir.children.clone();
let mut new_child = "/".to_owned() + line[1];
if pwd != *"/" {
new_child.insert_str(0, &pwd);
}
new_children.push(new_child);
let new_dir = Directory {
size: dir.size,
children: new_children,
};
directories.insert(dir_name.to_string(), new_dir);
}
} else if line[0] != "dir" {
if let Some((dir_name, dir)) = directories.get_key_value(&pwd) {
let new_dir = Directory {
size: dir.size + line[0].parse::<i64>().unwrap(),
children: dir.children.clone(),
};
directories.insert(dir_name.to_string(), new_dir);
}
}
}
let sizes = directories
.values()
.map(|directory| get_size(directory.clone(), directories.clone()));
let unused = TOTAL - sizes.clone().max().unwrap();
let mut sizes = sizes.collect::<Vec<i64>>();
sizes.sort();
for size in sizes {
if size >= (MIN_UNUSED - unused) {
return size;
}
}
0
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
584 i
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.log
5626152 d.ext
7214296 k";
#[test]
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 95437);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 24933642);
}
}

125
y2022/src/days/d8.rs Normal file
View File

@ -0,0 +1,125 @@
use std::collections::HashSet;
fn is_visible_from_line(tree_line: Vec<u32>, tree_height: u32) -> bool {
for &tree in tree_line.iter() {
if tree >= tree_height {
return false;
}
}
true
}
fn is_tree_visible(tree_grid: Vec<Vec<u32>>, tree_pos: (usize, usize), tree_height: u32) -> bool {
let horizontal_line = tree_grid[tree_pos.0].clone();
let vertical_line: Vec<u32> = tree_grid
.iter()
.map(|horizontal_line| horizontal_line[tree_pos.1])
.collect();
let (left, right) = vertical_line.split_at(tree_pos.0);
let (top, bottom) = horizontal_line.split_at(tree_pos.1);
is_visible_from_line(left.to_vec(), tree_height)
|| is_visible_from_line(right[1..].to_vec(), tree_height)
|| is_visible_from_line(top.to_vec(), tree_height)
|| is_visible_from_line(bottom[1..].to_vec(), tree_height)
}
pub fn process_part1(input: &str) -> u32 {
let tree_grid = input
.lines()
.map(|line| {
line.chars()
.map(|char| char.to_digit(10).unwrap())
.collect()
})
.collect::<Vec<Vec<u32>>>();
let dimension = (tree_grid.len(), tree_grid[0].len());
let outer_trees = (dimension.0 as u32 * 2) + (dimension.1 as u32 * 2) - 4;
let mut visible_trees: HashSet<(usize, usize)> = HashSet::new();
for x in 1..dimension.0 - 1 {
for y in 1..dimension.1 - 1 {
if is_tree_visible(tree_grid.clone(), (x, y), tree_grid[x][y]) {
visible_trees.insert((x, y));
}
}
}
outer_trees + visible_trees.len() as u32
}
fn seeing_distance(tree_line: Vec<u32>, tree_height: u32) -> u32 {
let mut count = 0;
for tree in tree_line {
count += 1;
if tree >= tree_height {
break;
}
}
count
}
fn calc_score(tree_grid: Vec<Vec<u32>>, tree_pos: (usize, usize), tree_height: u32) -> u32 {
let horizontal_line = tree_grid[tree_pos.0].clone();
let vertical_line: Vec<u32> = tree_grid
.iter()
.map(|horizontal_line| horizontal_line[tree_pos.1])
.collect();
let (left, right) = vertical_line.split_at(tree_pos.0);
let mut left = left.to_vec();
left.reverse();
let (top, bottom) = horizontal_line.split_at(tree_pos.1);
let mut top = top.to_vec();
top.reverse();
seeing_distance(left.to_vec(), tree_height)
* seeing_distance(right[1..].to_vec(), tree_height)
* seeing_distance(top.to_vec(), tree_height)
* seeing_distance(bottom[1..].to_vec(), tree_height)
}
pub fn process_part2(input: &str) -> u32 {
let tree_grid = input
.lines()
.map(|line| {
line.chars()
.map(|char| char.to_digit(10).unwrap())
.collect()
})
.collect::<Vec<Vec<u32>>>();
let dimension = (tree_grid.len(), tree_grid[0].len());
let mut highest_score = 0;
for x in 1..dimension.0 - 1 {
for y in 1..dimension.1 - 1 {
if is_tree_visible(tree_grid.clone(), (x, y), tree_grid[x][y]) {
let score = calc_score(tree_grid.clone(), (x, y), tree_grid[x][y]);
if score > highest_score {
highest_score = score;
}
}
}
}
highest_score
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "30373
25512
65332
33549
35390
";
#[test]
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 21);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 8);
}
}

229
y2022/src/days/d9.rs Normal file
View File

@ -0,0 +1,229 @@
use std::collections::HashSet;
#[derive(Clone, Copy, Debug)]
enum Move {
Up(i32),
Down(i32),
Left(i32),
Right(i32),
}
#[derive(Clone)]
struct Position {
head: (i32, i32),
tail: (i32, i32),
visited_positions: HashSet<(i32, i32)>,
}
impl Position {
fn new() -> Position {
Position {
head: (0, 0),
tail: (0, 0),
visited_positions: HashSet::from([(0, 0)]),
}
}
fn is_touching(&self) -> bool {
if self.head == self.tail {
return true;
}
if self.head.0.abs_diff(self.tail.0) <= 1 && self.head.1.abs_diff(self.tail.1) <= 1 {
return true;
}
false
}
fn update(&mut self, movement: Move) {
match movement {
Move::Up(distance) => {
for _ in 1..=distance {
self.step(Move::Up(1));
}
}
Move::Down(distance) => {
for _ in 1..=distance {
self.step(Move::Down(1));
}
}
Move::Left(distance) => {
for _ in 1..=distance {
self.step(Move::Left(1));
}
}
Move::Right(distance) => {
for _ in 1..=distance {
self.step(Move::Right(1));
}
}
}
}
fn square(a: i32) -> i32 {
a * a
}
fn get_distance(point_a: (i32, i32), point_b: (i32, i32)) -> f64 {
(Self::square(point_b.0 - point_a.0) as f64 + Self::square(point_b.1 - point_a.1) as f64)
.sqrt()
}
fn move_tail(&mut self, movement: Move) {
let big_distance = Self::get_distance(self.head, self.tail) > 2f64.sqrt();
if !&self.is_touching() {
match movement {
Move::Up(_) => {
self.tail.0 = self.head.0 - 1;
if big_distance {
self.tail.1 -= 1;
} else {
self.tail.1 = self.head.1;
}
}
Move::Down(_) => {
self.tail.0 = self.head.0 + 1;
if big_distance {
self.tail.1 += 1;
} else {
self.tail.1 = self.head.1;
}
}
Move::Left(_) => {
self.tail.1 = self.head.1 + 1;
if big_distance {
self.tail.0 += 1;
} else {
self.tail.0 = self.head.0;
}
}
Move::Right(_) => {
self.tail.1 = self.head.1 - 1;
if big_distance {
self.tail.0 -= 1;
} else {
self.tail.0 = self.head.0;
}
}
}
}
self.visited_positions.insert(self.tail);
}
fn step(&mut self, movement: Move) {
match movement {
Move::Up(distance) => self.head.0 += distance,
Move::Down(distance) => self.head.0 -= distance,
Move::Left(distance) => self.head.1 -= distance,
Move::Right(distance) => self.head.1 += distance,
}
self.move_tail(movement);
}
}
fn parse_line(line: &str) -> Move {
let mut line = line.split_whitespace();
let direction = line.next();
let distance = line.next().unwrap().parse::<i32>().unwrap();
match direction {
Some("U") => Move::Up(distance),
Some("D") => Move::Down(distance),
Some("L") => Move::Left(distance),
Some("R") => Move::Right(distance),
_ => panic!("Shouldn_t happen"),
}
}
pub fn process_part1(input: &str) -> usize {
let mut position = Position {
head: (0, 0),
tail: (0, 0),
visited_positions: HashSet::from([(0, 0)]),
};
let moves = input.lines().map(parse_line);
for movement in moves {
position.update(movement);
}
position.visited_positions.len()
}
pub fn process_part2(input: &str) -> usize {
let mut positions = vec![Position::new(); 10];
let moves = input.lines().map(parse_line);
for movement in moves {
let mut steps = 0;
if let Move::Up(distance) = movement {
steps = distance;
} else if let Move::Down(distance) = movement {
steps = distance;
} else if let Move::Left(distance) = movement {
steps = distance;
} else if let Move::Right(distance) = movement {
steps = distance;
}
for _ in 0..steps {
for (idx, position) in positions.clone().iter().enumerate() {
let mut position = position.clone();
if idx == 0 {
match movement {
Move::Up(_) => {
position.step(Move::Up(1));
}
Move::Down(_) => {
position.step(Move::Down(1));
}
Move::Left(_) => {
position.step(Move::Left(1));
}
Move::Right(_) => {
position.step(Move::Right(1));
}
}
println!("head: {:?}", position.head)
} else {
position.head = positions[idx - 1].tail;
position.move_tail(movement);
println!("knot nr{}: {:?}", idx, position.head);
}
if idx == 9 {
println!("tail: {:?}", position.tail)
}
positions[idx] = position;
}
}
}
positions[9].visited_positions.len()
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT1: &str = "R 4
U 4
L 3
D 1
R 4
D 1
L 5
R 2";
const INPUT2: &str = "R 5
U 8
L 8
D 3
R 17
D 10
L 25
U 20";
#[test]
fn part1() {
let result = process_part1(INPUT1);
assert_eq!(result, 13);
}
#[test]
fn part2() {
let result = process_part2(INPUT2);
assert_eq!(result, 36);
}
}

9
y2022/src/days/mod.rs Normal file
View File

@ -0,0 +1,9 @@
pub mod d1;
pub mod d2;
pub mod d3;
pub mod d4;
pub mod d5;
pub mod d6;
pub mod d7;
pub mod d8;
pub mod d9;

1
y2022/src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod days;

6
y2023/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2023"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2023/src/lib.rs Normal file
View File

6
y2024/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "y2024"
version = "0.1.0"
edition = "2021"
[dependencies]

0
y2024/src/lib.rs Normal file
View File