Compare commits
2 commits
9ce494d427
...
9c451e4428
Author | SHA1 | Date | |
---|---|---|---|
Tristan Daniël Maat | 9c451e4428 | ||
Tristan Daniël Maat | 561782748c |
1
day-5/.gitignore
vendored
Normal file
1
day-5/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target/
|
78
day-5/Cargo.lock
generated
Normal file
78
day-5/Cargo.lock
generated
Normal file
|
@ -0,0 +1,78 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "day-5"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"indoc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8"
|
||||
dependencies = [
|
||||
"indoc-impl",
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc-impl"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"unindent",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-hack"
|
||||
version = "0.5.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "unindent"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7"
|
10
day-5/Cargo.toml
Normal file
10
day-5/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "day-5"
|
||||
version = "0.1.0"
|
||||
authors = ["Tristan Daniël Maat <tm@tlater.net>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
indoc = "0.3"
|
815
day-5/input
Normal file
815
day-5/input
Normal file
|
@ -0,0 +1,815 @@
|
|||
BFBBFFFLRR
|
||||
FFBFBBBLLL
|
||||
FBFBFBFLLL
|
||||
BBFFFBFLLR
|
||||
FBFFBBFLRR
|
||||
BBFBFFFLLL
|
||||
FFBBFFFRLL
|
||||
BFBFBBBRRR
|
||||
FBFFBFFRLR
|
||||
FBBBBBBLLL
|
||||
BBFBBBBLLL
|
||||
BFFFBBBLLL
|
||||
FFBFFFBRLR
|
||||
BFFFFBFLLR
|
||||
FFBBBFBLRL
|
||||
BFFBFBBRRL
|
||||
FBFBFBBRRR
|
||||
FBFFFBBRRL
|
||||
FBFBBBFRLR
|
||||
BFFFFFBRRL
|
||||
BBFFFBBLRR
|
||||
FFBBBBBRRR
|
||||
FFBBBBBLLL
|
||||
BBFBFFBRLR
|
||||
FBFFBFBRRR
|
||||
FFFBBBBRLL
|
||||
BBFBFFBLLR
|
||||
BFBFFFBRLL
|
||||
FFBFBFFLLR
|
||||
FBFBBFBRLL
|
||||
FBFFBBBLLL
|
||||
FBFBBBFRLL
|
||||
FBFBFBBRLL
|
||||
BFFFFBBRLL
|
||||
FFFBBFFLLR
|
||||
FFBFFFBLRL
|
||||
FFBFBBFLLL
|
||||
BFBBFBBLLL
|
||||
BFFFFBBRRL
|
||||
FFBFFFBRLL
|
||||
BFBBFFFRRR
|
||||
FFBBFFFLRL
|
||||
FFBFBFBRLL
|
||||
BFBFBBBLLL
|
||||
BBFBBFFLRL
|
||||
BFFFFBBLLR
|
||||
FFBFBBFRLR
|
||||
FFBBFBBLLR
|
||||
FBFFBBFLLL
|
||||
BFBFBFBLLL
|
||||
BFFBFBBLLR
|
||||
FBBBBFFRLR
|
||||
FBBBFBFRLL
|
||||
FBBBBFFLRR
|
||||
BFFBBBBLRL
|
||||
FBFFBBFLRL
|
||||
BBFFFBBLLR
|
||||
FBFBFFFRLL
|
||||
FBBBFBBRRL
|
||||
FFBBBFBLLR
|
||||
BFFBBBFLLR
|
||||
BFFFFBFRLR
|
||||
BBFFFFBLLR
|
||||
FBBFFFBRRL
|
||||
BFFFBFBRRR
|
||||
FBFBFFFRRR
|
||||
BBBFFFBLRL
|
||||
BFBFBFBLLR
|
||||
BFBBBBBLRL
|
||||
FFBBFBBRRR
|
||||
FBBFFFBRRR
|
||||
FFBFBFBRRR
|
||||
BBFFFFBRRL
|
||||
BFBBBBBLLL
|
||||
BFBFBFFRLL
|
||||
BFBFBFBRRL
|
||||
BFBFFFFLRL
|
||||
FFBBBBBLLR
|
||||
FBBFBFFRLL
|
||||
FBBFFBBLLL
|
||||
BFFFFFFLRL
|
||||
FFFBBFFLRL
|
||||
FFFBBFFRLL
|
||||
FFBFFFBLLL
|
||||
FBBFBFBLRL
|
||||
BBFFFFBRLR
|
||||
FBBFBBBRLR
|
||||
FFBBFFBLLL
|
||||
FFBFFFBRRR
|
||||
FBFBFBFRRL
|
||||
FFBBBFBRRL
|
||||
BBFFBFFLRR
|
||||
FBFFFFFRRR
|
||||
FBBFFFBRLL
|
||||
FFBBFBBRRL
|
||||
FFBBFFFLLR
|
||||
FBFBBFBLLL
|
||||
BFFFBBFLRR
|
||||
BFBFBFFLRR
|
||||
BFFFFBFRRR
|
||||
BBFBBFFRLL
|
||||
BFBBBBBLRR
|
||||
BFBBBBFLLL
|
||||
BBFBBBBLLR
|
||||
FFBBBFFRRR
|
||||
BBFFBFBLRR
|
||||
FFFBBBFRLR
|
||||
BFBFFFBLRR
|
||||
BFFFBBFLLL
|
||||
FBBBBFFLRL
|
||||
FBBFFFFRRL
|
||||
FFBFFBBRRL
|
||||
BFBBBBBRLR
|
||||
FBBFFBBLRL
|
||||
BBFBFBBRLL
|
||||
FBFFBFBRLR
|
||||
FBBBBFFLLR
|
||||
FBBFBBFRRL
|
||||
FBFBBBBRLL
|
||||
BFFBFBFRLL
|
||||
FFBFBBFRRL
|
||||
FBFFFBFRRL
|
||||
FBFFBBFRRL
|
||||
FFBFBBFRLL
|
||||
BBFBBBBLRL
|
||||
BFFFBBBRRL
|
||||
FFBFFFBLRR
|
||||
FFBBFBBLRL
|
||||
BFBFBBFRRR
|
||||
BFFFFFFRRL
|
||||
FBBBBBBRRR
|
||||
FBFBBFBLRR
|
||||
FBFFFFFRLR
|
||||
BFFBBBFLRR
|
||||
BFBBFFBLLL
|
||||
FBFFFFBLRL
|
||||
FFBBBBBLRL
|
||||
FFFBBBFRLL
|
||||
FFBBFBFRLL
|
||||
FBFBBBFLRL
|
||||
FFBBBFBRLL
|
||||
BBFBBFBLRL
|
||||
FFBFBFFRLR
|
||||
BBFBBBBLRR
|
||||
FFFBBBBRRR
|
||||
FBBBFBFLLL
|
||||
BFFFBFBRLR
|
||||
FBBFBBFRRR
|
||||
FBFFBBBRLR
|
||||
FBFBBFBRLR
|
||||
FBBBFBBLLL
|
||||
BBFBFBFLLL
|
||||
FFBBFBBRLL
|
||||
FBBFBBBLRR
|
||||
BFFFBBFRRL
|
||||
BFBFFBFLRR
|
||||
BBFBBBFLLL
|
||||
BFFFBBFRLR
|
||||
BFBBFBFLRL
|
||||
FBBBBBFRRR
|
||||
FBFFFBBRRR
|
||||
BBFFFFBLRR
|
||||
FBFBFBFLRL
|
||||
BBFFBBBRLL
|
||||
FFBBBFFLRR
|
||||
FFBBBBFLRR
|
||||
FBFBFBBRRL
|
||||
BBFBFFBRRL
|
||||
FBBBFFBLLL
|
||||
BFBFFFFLLR
|
||||
FFBFFBFLRR
|
||||
BFBBFFFLLR
|
||||
BBFBBFFLRR
|
||||
BFFFFFFLLR
|
||||
BBFFBFBRRL
|
||||
FBBBFBBRLL
|
||||
BFBBBFBLLR
|
||||
BFBBFFBRLR
|
||||
FBFBBBFRRR
|
||||
BFBBBBBRRR
|
||||
FFBBFBBRLR
|
||||
FBBFBBFRLR
|
||||
BFFBBFBRLR
|
||||
FBFFFFFLLL
|
||||
FBBFFBFRLL
|
||||
FBBBBFFRRL
|
||||
FBFBBBBLRL
|
||||
FFFBBFBLRR
|
||||
FFBFFBBLRR
|
||||
FFBBBBBLRR
|
||||
FBBFFBFRRR
|
||||
FBBBFBFRRR
|
||||
FBBFBBBLLR
|
||||
BFFFFBFLLL
|
||||
FFBFFFFRRL
|
||||
BFBFFBBLRL
|
||||
FFBFFFFRLR
|
||||
FBFBFBFRLL
|
||||
BBFBFBBRRL
|
||||
FFBFBBFLLR
|
||||
BFBBFFBLLR
|
||||
FBFFBFFLLL
|
||||
BFFBBFBRRR
|
||||
FBFFFBBRLL
|
||||
BBFBBFFRRR
|
||||
FBFBBFBLRL
|
||||
FBFBFBBLRL
|
||||
FBFFBBFRRR
|
||||
FBFFBBBLRL
|
||||
FFBFBBBRRR
|
||||
BFBBBFFLLR
|
||||
FFBBFFFRRL
|
||||
FFBBBBBRRL
|
||||
FFBFFBBRLL
|
||||
FFBBFBFLLR
|
||||
FBBBFBFLLR
|
||||
BFFFBFFRLL
|
||||
FFBBBFBLRR
|
||||
BFFBBBFRRR
|
||||
BFBBFBBRRR
|
||||
BBFBFFFRRR
|
||||
FBBFFFBLRL
|
||||
BBFBBBFLLR
|
||||
BBFFFBBLRL
|
||||
FBBFFFFLRR
|
||||
BFFBFFFRRL
|
||||
FFBFBBBRLL
|
||||
BBFBBFBRLL
|
||||
FBFFFBBLRR
|
||||
BFBFBBFRLL
|
||||
FBFBBBBRRL
|
||||
FFFBBBFLLR
|
||||
FBFFFFBRRR
|
||||
FBBBBBBRLR
|
||||
BBFBFBFRRR
|
||||
BFBFFBFRLL
|
||||
BFBBBFFLLL
|
||||
BFBBBFBLLL
|
||||
FBFFBFBLRL
|
||||
FFBFFFFLLR
|
||||
FBBBBBFLLL
|
||||
BBFFBFBLLR
|
||||
BBFBBBFLRR
|
||||
BFFFFFFRRR
|
||||
BFFBFFBRRR
|
||||
BFFBBFFLLL
|
||||
FFFBBBFLLL
|
||||
BFFBBFFRRR
|
||||
BBFBBBBRRL
|
||||
FBFBBFFLRR
|
||||
BFBFFBBLLR
|
||||
BFBFFBBRRL
|
||||
BFBBFFFLLL
|
||||
BFBFFBBRRR
|
||||
BFBBFBFRRL
|
||||
FBFBFFFLLR
|
||||
BFBFBFFLLR
|
||||
BFBBBBFRRL
|
||||
BFFFBFFLRR
|
||||
FBBFBBBRRL
|
||||
BBFFFBBRLL
|
||||
FFBFBBBLRR
|
||||
FFBBFFBRLL
|
||||
FBBBFBFRRL
|
||||
FFBFFFFLRL
|
||||
BFFFBBBRLL
|
||||
BFBBBFFRRR
|
||||
FFBFFBBRRR
|
||||
BFBFFFBLLR
|
||||
FBFFFBFLLR
|
||||
FBFBBFFRRL
|
||||
FFBFFBBLLL
|
||||
BBFBBBFLRL
|
||||
BFBFBBFRRL
|
||||
BFFFBFFLLL
|
||||
FBBBFFFRLL
|
||||
BBBFFFFLLR
|
||||
BFFBFFBLRL
|
||||
BBFFBBBLLL
|
||||
BFFBFFBLLR
|
||||
BBFFBBBLRL
|
||||
FBBFFBBLLR
|
||||
FFBFBBFRRR
|
||||
FBFBBFBRRR
|
||||
BFBFFBFRLR
|
||||
BFBBBFBRLL
|
||||
FFBBBBFLRL
|
||||
BFFBFBFLLR
|
||||
BFBBFFFRLL
|
||||
BBFBFBBLRR
|
||||
FBBFBFFLLL
|
||||
FBBFFFFLRL
|
||||
FBBBBFBRRL
|
||||
FFBBBFFRLL
|
||||
FBBFBFFRRL
|
||||
FBBBFBFRLR
|
||||
FBBBFFBLRR
|
||||
BBFFBBBLRR
|
||||
FBBFFBFLLL
|
||||
FBFBBFFRLL
|
||||
FFBFBFFRLL
|
||||
BFBFBBBRRL
|
||||
FBFBBBFRRL
|
||||
FFBFBBBLLR
|
||||
BFFBFFFRLR
|
||||
FFBFBFFRRL
|
||||
BBFFFFFLRL
|
||||
FBFFBFFLRL
|
||||
BBFFFBFLLL
|
||||
BFFBBFBLRR
|
||||
BFBBFBFLLR
|
||||
FBFBFBFLRR
|
||||
BBFFBBFRLL
|
||||
BBFBFBFRLL
|
||||
BBFFFBFRLR
|
||||
BFFBFBFRRL
|
||||
BFFBFBBLRL
|
||||
FFFBBBFLRL
|
||||
FBBBFFFRRL
|
||||
FFBFBBFLRR
|
||||
FBBFBFBRLR
|
||||
FFFBBFFRRR
|
||||
FBBBBBBLRL
|
||||
BBFFBBFRRR
|
||||
FFBFFBFLLL
|
||||
BFFFBBFLRL
|
||||
FBFBBBFLRR
|
||||
BBFFBFBLLL
|
||||
FBFFBBFRLR
|
||||
BFFBFBBLLL
|
||||
BFBBFFBLRR
|
||||
FFBBBFFLLR
|
||||
FBFBFFFRRL
|
||||
BFBBFBBRLL
|
||||
BBFBBFBLRR
|
||||
FBBFFFFLLR
|
||||
BFFFBBFRRR
|
||||
BBFFFBFRRR
|
||||
BBFBBFFLLL
|
||||
BBFFBFBRLL
|
||||
BBBFFFFRLR
|
||||
BFFFFBFRLL
|
||||
FFBBBFFRRL
|
||||
BFFBBBFLRL
|
||||
BBFBBBFRLL
|
||||
FBFFFFBRLL
|
||||
BFBFFBFLRL
|
||||
FFBFFBBLRL
|
||||
FBBBBBBLRR
|
||||
BBFFFBFRLL
|
||||
BFBFFBBRLR
|
||||
BBFBFFBLLL
|
||||
BFFFBFFRRR
|
||||
FFBFFBFLRL
|
||||
FBBFBFFLRR
|
||||
BBFBFFBRRR
|
||||
BBFBFFBLRL
|
||||
FBBBBFBLRR
|
||||
BBFFBBBRRR
|
||||
BBFFBFFLLR
|
||||
FBBBFFBRLL
|
||||
BFBFFBBLLL
|
||||
FBBFBBBLLL
|
||||
FFBBFBBLRR
|
||||
FBBBBFFLLL
|
||||
BFBFBBFLRL
|
||||
BFBBBFBRRL
|
||||
BFBBBBFRLL
|
||||
FFBBFFFRLR
|
||||
BBFBBBFRLR
|
||||
BFBBFBBRLR
|
||||
FFFBBBBLLL
|
||||
BFFFFFBLRL
|
||||
FBFBFFBRLL
|
||||
FBBFBBBRLL
|
||||
FBBFBBFRLL
|
||||
BFBFBBFLLR
|
||||
FFBBFBFLRL
|
||||
FBBBFFBRRL
|
||||
FFBFFBFRRR
|
||||
BBFFFFBRLL
|
||||
FBBFFBFRRL
|
||||
BBFFFFFRLR
|
||||
FBFBFFBLRR
|
||||
BFFBBFBRLL
|
||||
BBFFFFFLRR
|
||||
BBFFBBBRRL
|
||||
BBFFBFFRLR
|
||||
FFBBFFBLLR
|
||||
FBBFFFBLRR
|
||||
BFFBBBBRLL
|
||||
FBFBFBBLRR
|
||||
FBBFBFBRLL
|
||||
FBBBFFFRRR
|
||||
FBBFFBBRLL
|
||||
FFBFFFFRLL
|
||||
FFBBBFBLLL
|
||||
FBFFBBBLRR
|
||||
FFBBFFBRRR
|
||||
FFFBBFBRRR
|
||||
FBFBFFBRRR
|
||||
FFBFFBFRLR
|
||||
BFFFFFFLLL
|
||||
FFBFFBFRRL
|
||||
BFBFBFFLLL
|
||||
BFFBBBBRRR
|
||||
BFFBBFBRRL
|
||||
BBFFBBBRLR
|
||||
BBFFBFFRRR
|
||||
BBFBFBFRLR
|
||||
FFBBFBFLRR
|
||||
FBFFBFBLRR
|
||||
BBFBBBBRLL
|
||||
BBFFFFFLLL
|
||||
FBFFBFFLRR
|
||||
BBBFFFBRRL
|
||||
BFFBFFBRRL
|
||||
BFBBBFBRRR
|
||||
FFFBBFBRLL
|
||||
BFFBBFBLLR
|
||||
BFBBBBFRLR
|
||||
BFFFFBFLRL
|
||||
FBBFBFBRRR
|
||||
BFFBFBBLRR
|
||||
BBFBBFBLLL
|
||||
FBFBFFBRLR
|
||||
FFBBBBFRLL
|
||||
BFBFFBBRLL
|
||||
BBFBBBBRLR
|
||||
FFFBBBBLRL
|
||||
FFFBBFBLLR
|
||||
BFBBFBFLRR
|
||||
FFFBBFBLRL
|
||||
FBBBBBFLLR
|
||||
FBFFBFBRLL
|
||||
BFBFBBBRLL
|
||||
BFBBBBFRRR
|
||||
FBBFBFBRRL
|
||||
BBFFBBFRLR
|
||||
FFFBBBBRLR
|
||||
BFBFBBBLRR
|
||||
FBBBBFBRLR
|
||||
BBFBFBBLRL
|
||||
FFBBBFFRLR
|
||||
BFBBBFFLRR
|
||||
FBFBBBBLRR
|
||||
FBBFFFBRLR
|
||||
BFFFFFBLRR
|
||||
BFFBBBBRLR
|
||||
FBBBFFFRLR
|
||||
BBBFFFFLRR
|
||||
BFBFBFBRRR
|
||||
FFBFFBFRLL
|
||||
BBFBFBFLRR
|
||||
BFBBFBBLLR
|
||||
FFBBBBBRLL
|
||||
FFFBBBBLRR
|
||||
FBBFBBFLRL
|
||||
BFFFBFBLLL
|
||||
BFBFFFFRLL
|
||||
FBFFFBFLRL
|
||||
BBFFFFFRRR
|
||||
FBBFBBFLLL
|
||||
FBBFBFFRLR
|
||||
FFFBBFFLRR
|
||||
BFBBFFFRRL
|
||||
FBFFFBBRLR
|
||||
BBFBFFFRLL
|
||||
FBBFFBBRRL
|
||||
BBBFFFFRLL
|
||||
BFBBBBBRLL
|
||||
FFFBBFFRRL
|
||||
FBBFFFBLLR
|
||||
BFFFBFFLLR
|
||||
FFBFFBFLLR
|
||||
FBBFFBBRRR
|
||||
BFFFFFBRLL
|
||||
BFFFBFFRRL
|
||||
BBFBBBFRRR
|
||||
BFFBFBFLRR
|
||||
FBFBBFFRLR
|
||||
BBFFFBFLRR
|
||||
BBFBFBFLLR
|
||||
BFFBBBFLLL
|
||||
FBFBFBBLLR
|
||||
FBBBBBBRLL
|
||||
FBFBFFFLRL
|
||||
FFBBFFBRLR
|
||||
BBFBBFBRRL
|
||||
BBFBBFBRLR
|
||||
BFFBBFFLRR
|
||||
BFFBFFFLRR
|
||||
BFBFBFFRRL
|
||||
BBFBBBBRRR
|
||||
FBFFFFFLLR
|
||||
BBFFBBFLLR
|
||||
BFFFBBBRLR
|
||||
FBBBBFFRLL
|
||||
BBFBBFFRRL
|
||||
BBFFBFFRLL
|
||||
BFBFBFBLRL
|
||||
BFBFFFBLLL
|
||||
BBFBFFFRLR
|
||||
FBBBFFFLRL
|
||||
FFFBBBBLLR
|
||||
FFBFFFFLRR
|
||||
BBFBFBFRRL
|
||||
FBFFBBBRLL
|
||||
FBBBFBBLRL
|
||||
BBBFFFFLLL
|
||||
FFBFBBBRRL
|
||||
FBFBFFBLLR
|
||||
FBFFFFFLRL
|
||||
BFBFBBBLRL
|
||||
BFFBBFFRLR
|
||||
BFBFFBBLRR
|
||||
BFFBFBBRLR
|
||||
FBBFBFBLRR
|
||||
FFBBBFFLRL
|
||||
BBFFBBFLRR
|
||||
FBBBFBBRRR
|
||||
BFFFBBBLLR
|
||||
BFBFBBBRLR
|
||||
BFFBFBFLLL
|
||||
BBBFFFBRRR
|
||||
BBBFFFBRLR
|
||||
FBFBBFFLLL
|
||||
BFFBBFFLLR
|
||||
FFBBFFBLRR
|
||||
FBBBBBFRLR
|
||||
BFBBFFBRRL
|
||||
FBBBFFFLRR
|
||||
FBFFFFFRLL
|
||||
FFBFFFBLLR
|
||||
BFFBFFFRLL
|
||||
BFBFBFBRLL
|
||||
BFFFFBBLRR
|
||||
FBBFFBBLRR
|
||||
BFBBBFBLRL
|
||||
BBFBFBBLLR
|
||||
BFBBBFBLRR
|
||||
FBFFFBFLLL
|
||||
BFBBBBBLLR
|
||||
BFBFFFBRLR
|
||||
BFBFBBFLLL
|
||||
BBBFFFFRRR
|
||||
FBBFFBBRLR
|
||||
BBBFFFFLRL
|
||||
FBBFBBBRRR
|
||||
FFBBFBFRRL
|
||||
BFFFBBBRRR
|
||||
FFBFBFFRRR
|
||||
BBFBFFFLRR
|
||||
FFBFBBBLRL
|
||||
BFBFBFFRLR
|
||||
FFBBFFFRRR
|
||||
FBFFBFBLLL
|
||||
FBFFBFBLLR
|
||||
BBFBBFFLLR
|
||||
BFBBBFFRLR
|
||||
BFFFFBBLLL
|
||||
BFFBFFBRLL
|
||||
FBBFFFFRLL
|
||||
FFBFBFBLRR
|
||||
FBBBBFBLLL
|
||||
BFBFBFBRLR
|
||||
FBBFBBBLRL
|
||||
BFBFFBFRRL
|
||||
FBBFBFBLLL
|
||||
BFFFBFBLRL
|
||||
BBFFBFFLLL
|
||||
BBFFFBFLRL
|
||||
FFFBBBFRRL
|
||||
FBBFFFBLLL
|
||||
BFFFFFBLLR
|
||||
FBBBBFBRLL
|
||||
BFFFFBBRRR
|
||||
BFFFFBBLRL
|
||||
FBBFFBFRLR
|
||||
BBFFFFBRRR
|
||||
FBFFFFBLLL
|
||||
FFBFBFBRLR
|
||||
BFFFBBBLRL
|
||||
BFFFFFFRLL
|
||||
BFBFFBFLLR
|
||||
BBFFFBBRLR
|
||||
FBBBBFBLRL
|
||||
FBBBBFBRRR
|
||||
BFFBFFFLLL
|
||||
BFFBBBFRLL
|
||||
BFBFBBFRLR
|
||||
BBFFBFBRLR
|
||||
FBBBBBFLRR
|
||||
BFBBFBFRLR
|
||||
FFBBFBFRLR
|
||||
BFFFFFBRRR
|
||||
BFFBBFFLRL
|
||||
FBFFBFFRRL
|
||||
BFBBFFFLRL
|
||||
FBFFFBBLRL
|
||||
BFFFBFFRLR
|
||||
BFFFBFBRRL
|
||||
FBBBBBFLRL
|
||||
BBFFBBFLLL
|
||||
FFBBFBBLLL
|
||||
FFBFBFFLLL
|
||||
BBBFFFBLLL
|
||||
BFBFBBBLLR
|
||||
FBBFFBFLRL
|
||||
FBBBBFFRRR
|
||||
BFBBBBFLLR
|
||||
FFBFFFFRRR
|
||||
BBFFBBFLRL
|
||||
FBFBFBBRLR
|
||||
BFBBFFBLRL
|
||||
FBFBFFBLLL
|
||||
BBFFBFFLRL
|
||||
FBFBFFFLRR
|
||||
FFBFBFBLRL
|
||||
BFFBFBBRRR
|
||||
FFBFBBBRLR
|
||||
BFBBFFFRLR
|
||||
BFBFFFFRLR
|
||||
FFFBBFFLLL
|
||||
BFBFFFFLLL
|
||||
FFBFFBBRLR
|
||||
FFBFBFFLRR
|
||||
BFFBBFFRLL
|
||||
BBFFBBBLLR
|
||||
BFBBBBBRRL
|
||||
FBFBBBBRRR
|
||||
FBBFFFFRRR
|
||||
FFBBBFBRLR
|
||||
FFBFBFBLLL
|
||||
BFFBFFFLLR
|
||||
FBFBFBFRRR
|
||||
BFFBBBBLLL
|
||||
BFFFFBBRLR
|
||||
FBFBBFFLRL
|
||||
FFBFBFFLRL
|
||||
FBBBFFBLLR
|
||||
FBBFBFFLRL
|
||||
FFBFBBFLRL
|
||||
BBBFFFFRRL
|
||||
FFBBFBFLLL
|
||||
FFBBBBFRRL
|
||||
BBFFFFBLLL
|
||||
FFBBFBFRRR
|
||||
FBFFFFFLRR
|
||||
BFFBBBBRRL
|
||||
BFBBFBBRRL
|
||||
BBFBFBBRLR
|
||||
FFBFFFFLLL
|
||||
FBBFBFBLLR
|
||||
FBFBFFBLRL
|
||||
BBFBFBBRRR
|
||||
BFFBBFBLRL
|
||||
FFBBBFFLLL
|
||||
FBBBFFFLLL
|
||||
BFFFBFBLLR
|
||||
FFBBFFFLLL
|
||||
BFFBFFBLRR
|
||||
FFBBFFFLRR
|
||||
BFFBFBBRLL
|
||||
FFBFBFBLLR
|
||||
FBBBBBBLLR
|
||||
FBFFFFBRLR
|
||||
BFBBBFFRLL
|
||||
FFBBBBFRLR
|
||||
FFBFFBBLLR
|
||||
BBFFFFFLLR
|
||||
FBFFFBFRLR
|
||||
BFBFFFFRRL
|
||||
FBFFFBBLLL
|
||||
BBFFFBBLLL
|
||||
BFFBFBFLRL
|
||||
BBFFFBFRRL
|
||||
FBFFBBBRRR
|
||||
FBFFFBBLLR
|
||||
FFFBBFBRRL
|
||||
BBFBFFFLRL
|
||||
BFBFFFBRRL
|
||||
BFBBBFBRLR
|
||||
BFFFBBBLRR
|
||||
FBBFBFFLLR
|
||||
FBFBBBBRLR
|
||||
BBFBBBFRRL
|
||||
FFFBBFBRLR
|
||||
BFFBFFFLRL
|
||||
FBBBBBBRRL
|
||||
BFFBFFBLLL
|
||||
BFFBBFFRRL
|
||||
FBBFBBFLLR
|
||||
BFFBBBBLLR
|
||||
BFBBBFFLRL
|
||||
BFBFFBFRRR
|
||||
BBFFFBBRRL
|
||||
BFBFBFFLRL
|
||||
BFBBFFBRLL
|
||||
BFFFFFFLRR
|
||||
FFFBBBFLRR
|
||||
FBBFFFFLLL
|
||||
FFBBFFBRRL
|
||||
BFBFFBFLLL
|
||||
FBFBBBFLLR
|
||||
FFBBBBBRLR
|
||||
BBFBFFBRLL
|
||||
FBFBBFBRRL
|
||||
FBBFFBFLRR
|
||||
BFFFFFBRLR
|
||||
FBFBBFBLLR
|
||||
FBBBFFFLLR
|
||||
BFFFFBFRRL
|
||||
FBFFFFFRRL
|
||||
FBFBFFFRLR
|
||||
FBFBBBFLLL
|
||||
BBFBFFBLRR
|
||||
BFBBBFFRRL
|
||||
BFBBFBFRRR
|
||||
BBFFFFFRLL
|
||||
FBFBFBFRLR
|
||||
FBBBBBFRLL
|
||||
BBFFBFBLRL
|
||||
BBFFBBFRRL
|
||||
BFBFFFFLRR
|
||||
FBFFBBBRRL
|
||||
FFFBBFFRLR
|
||||
BBFFBFFRRL
|
||||
BBFBBFBLLR
|
||||
FBBFFBFLLR
|
||||
FBFFFFBLLR
|
||||
FFBFBFBRRL
|
||||
FBFFFFBLRR
|
||||
BFFBFFFRRR
|
||||
FFFBBBFRRR
|
||||
BFBFBFBLRR
|
||||
FBFBBBBLLR
|
||||
BBFFFFBLRL
|
||||
BFBBFBFLLL
|
||||
FBBBFFBLRL
|
||||
BBFBFFFRRL
|
||||
BBBFFFBRLL
|
||||
FBBFBBFLRR
|
||||
FBFBFFFLLL
|
||||
FBBFFFFRLR
|
||||
BFFBBBFRRL
|
||||
BBFFFBBRRR
|
||||
FBBBFFBRLR
|
||||
FFBFFFBRRL
|
||||
BFFFFFBLLL
|
||||
FBFFFBFRLL
|
||||
BBFFBFBRRR
|
||||
BFFFFBFLRR
|
||||
FFBBBBFLLR
|
||||
BFBFBBFLRR
|
||||
FBFBFBBLLL
|
||||
BFFFBFBLRR
|
||||
BBFBBFBRRR
|
||||
BFBBFBBLRL
|
||||
BBFBFBBLLL
|
||||
FBBBFBFLRL
|
||||
BFFFBBFRLL
|
||||
FBBBBBFRRL
|
||||
BFFBFFBRLR
|
||||
BFFBBBBLRR
|
||||
FFFBBFBLLL
|
||||
BFBBBBFLRL
|
||||
FBBBFBFLRR
|
||||
FBFFFBFLRR
|
||||
BFBFFFBRRR
|
||||
FBFFBFFLLR
|
||||
BFBFBFFRRR
|
||||
BFFBFBFRLR
|
||||
FBFFFFBRRL
|
||||
BFFFBFBRLL
|
||||
FBBBFBBLRR
|
||||
BFBBFFBRRR
|
||||
BFBFFFFRRR
|
||||
BFFBFBFRRR
|
||||
FFBBFFBLRL
|
||||
BFBBBBFLRR
|
||||
FBFFBBBLLR
|
||||
FBFBBFFLLR
|
||||
FBFFFBFRRR
|
||||
FBFBBBBLLL
|
||||
BFBBFBBLRR
|
||||
BFBFFFBLRL
|
||||
BFFBBFBLLL
|
||||
FBFFBBFLLR
|
||||
BBFBFFFLLR
|
||||
BBFFFFFRRL
|
||||
FBFBBFFRRR
|
||||
BFFFBFFLRL
|
||||
FBFBFBFLLR
|
||||
BFFFFFFRLR
|
||||
FFBBBBFRRR
|
||||
BBFBFBFLRL
|
||||
FBBBFFBRRR
|
||||
FBFFBFFRRR
|
||||
FBBBBFBLLR
|
||||
BBBFFFBLLR
|
||||
FBFFBFBRRL
|
||||
FBBBFBBRLR
|
||||
FBFFBBFRLL
|
||||
BBBFFFBLRR
|
||||
BFFFBBFLLR
|
||||
FBFFBFFRLL
|
||||
FFBBBBFLLL
|
||||
FFBBBFBRRR
|
||||
BBFBBFFRLR
|
||||
FBBBFBBLLR
|
||||
FBBFBFFRRR
|
||||
BFBBFBFRLL
|
||||
FFFBBBBRRL
|
||||
FBFBFFBRRL
|
114
day-5/src/main.rs
Normal file
114
day-5/src/main.rs
Normal file
|
@ -0,0 +1,114 @@
|
|||
use std::fs;
|
||||
|
||||
type SeatCode = [char; 10];
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let input = fs::read_to_string("input")?;
|
||||
|
||||
// Part 1
|
||||
let max_id: Result<usize, String> = input
|
||||
.lines()
|
||||
.map(|code| {
|
||||
let (row, col) = find_seat(parse_seatcode(code)?);
|
||||
Ok(row * 8 + col)
|
||||
})
|
||||
.max()
|
||||
.ok_or("No seat codes set")?;
|
||||
|
||||
println!("{}", max_id?);
|
||||
|
||||
// Part 2
|
||||
let mut ids = input
|
||||
.lines()
|
||||
.map(|code| {
|
||||
let (row, col) = find_seat(parse_seatcode(code)?);
|
||||
Ok(row * 8 + col)
|
||||
})
|
||||
.collect::<Result<Vec<usize>, String>>()?;
|
||||
ids.sort();
|
||||
|
||||
let mut previous = ids[0];
|
||||
for id in &ids[1..] {
|
||||
if id - 1 != previous {
|
||||
println!("{}", id);
|
||||
break;
|
||||
} else {
|
||||
previous = *id;
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_seatcode(input: &str) -> Result<SeatCode, String> {
|
||||
let mut output = ['0'; 10];
|
||||
|
||||
for (i, c) in input.chars().enumerate() {
|
||||
if i > 10 {
|
||||
Err(format!("Seat code too long: '{}'", input))?;
|
||||
}
|
||||
|
||||
if !['F', 'B', 'L', 'R'].iter().any(|valid| &c != valid) {
|
||||
Err(format!("Invalid character in seat code: '{}'", input))?;
|
||||
}
|
||||
|
||||
output[i] = c;
|
||||
}
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
fn find_seat(code: SeatCode) -> (usize, usize) {
|
||||
let midpoint = |(start, end): (usize, usize)| (start + end) / 2;
|
||||
let binary_follow = |range: (usize, usize), direction: &char| match direction {
|
||||
'F' | 'L' => (range.0, midpoint(range)),
|
||||
'B' | 'R' => (midpoint(range) + 1, range.1),
|
||||
_ => unreachable!("We already checked all characters are valid"),
|
||||
};
|
||||
|
||||
let row = code[..7].iter().fold((0, 127), binary_follow).0;
|
||||
let col = code[7..].iter().fold((0, 7), binary_follow).0;
|
||||
|
||||
(row, col)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_simple() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let input = "FBFBBFFRLR";
|
||||
let seat = find_seat(parse_seatcode(input)?);
|
||||
|
||||
assert_eq!(seat, (44, 5));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple2() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let input = "BFFFBBFRRR";
|
||||
let seat = find_seat(parse_seatcode(input)?);
|
||||
|
||||
assert_eq!(seat, (70, 7));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple3() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let input = "FFFBBBFRRR";
|
||||
let seat = find_seat(parse_seatcode(input)?);
|
||||
|
||||
assert_eq!(seat, (14, 7));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple4() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let input = "BBFFBBFRLL";
|
||||
let seat = find_seat(parse_seatcode(input)?);
|
||||
|
||||
assert_eq!(seat, (102, 4));
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue