Compare commits
3 commits
master
...
tlater/day
Author | SHA1 | Date | |
---|---|---|---|
Tristan Daniël Maat | f38ec71c3f | ||
Tristan Daniël Maat | 5a7cd20ca6 | ||
Tristan Daniël Maat | 74819475ca |
141
day-11/Cargo.lock
generated
Normal file
141
day-11/Cargo.lock
generated
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day-11"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"indoc",
|
||||||
|
"ndarray",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 = "matrixmultiply"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1"
|
||||||
|
dependencies = [
|
||||||
|
"rawpointer",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ndarray"
|
||||||
|
version = "0.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c0d5c9540a691d153064dc47a4db2504587a75eae07bf1d73f7a596ebc73c04"
|
||||||
|
dependencies = [
|
||||||
|
"matrixmultiply",
|
||||||
|
"num-complex",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"rawpointer",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-complex"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 = "rawpointer"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.54"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
|
||||||
|
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"
|
11
day-11/Cargo.toml
Normal file
11
day-11/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "day-11"
|
||||||
|
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"
|
||||||
|
ndarray = "0.14"
|
93
day-11/input
Normal file
93
day-11/input
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLLLLLLL.LLLL.LLLLLLLL.LLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLL.LL.LLLLLLLL.LLLLL.LLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLL.LLLLL.L.LLLLLLLLLLLLLLL.LLLLLL.LLLL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LLLLLL.LLLL.L.LLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLL..LLLLLLLLLLLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LL.LLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLLLLLLL.LLL.LLLLLLLLL.LLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
..L.L.LL.L..LL..L..LL.L..L................L....L............L.L..L...L...L..LLLL....L.L..LL....L.
|
||||||
|
LLLLLL.LLL.LLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.L.LLLLLL.LLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLL.LLL.LLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLL.LLL.L.LLL.LLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LL.L.L.L.....L..L...L.L...L.......L...LLL...L.LL.L.....L.LLL.LL....LLLLL.L....LLL.L..LL..L....L.L
|
||||||
|
LLLLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLL.LLLLLLLLLLL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LLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
.....L.L..LL..LL..L.L.L.....LLLLL.....L..L...L.....L.L..L..L....LL....L...........L.L.......L.LLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLL.LLLLLL.LLLL.LLLL.LLLLLLLL.LLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLL..LLLLLLL.LLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLLLLLLLL.LLLLLLL.L.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
LLLL.L.LLL.LLLL.LLLL.LLLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLLLLLLLLL.LLLLLLLL.LL.L.LLLLLLLL
|
||||||
|
L.LLL.................LLL....L...LL..........L.L.L.......L.....L.....LLLLLL......L.......L...L.LL
|
||||||
|
LLLLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL.LL.LLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLL.LLLLL.LL
|
||||||
|
LLLLLLLLLL.LLL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LLLLL.LLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLL.LL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLLLLL.LLLLL.LLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLLLLLLLLLLL.LL.LL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLL.LLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LL.L.L..LL..L.......L.L..LL....L.L.L...L.L..LL....LL.LL....L....LL..L....L............L.......L..
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLL.LLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLL.LLLLLL.L.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLL.LLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
||||||
|
..L.L.....L......L..L.....L.......L..L....LL...L.L.L...LLL.L.L..L..L..L......LLL.....L..L..L.....
|
||||||
|
LLLLLLLLLLLLLLL.LLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLL.LLLLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLLL.LLLLLLLLLLLL.LLLLLL.L.LLLLLL.LLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLL..LLLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLL.LLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLL.LLLLLLLL
|
||||||
|
LLLLLLLLLL.LLLLLLLLL.LL.LLLLL.LLLLLLLLLLLLL.LLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLL
|
121
day-11/src/main.rs
Normal file
121
day-11/src/main.rs
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
use std::fs;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
|
use ndarray::Array2;
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let input = fs::read_to_string("input")?;
|
||||||
|
let layout = parse_layout(&input)?;
|
||||||
|
|
||||||
|
// Part 1
|
||||||
|
let result = count_with_neighboring_seats(&layout);
|
||||||
|
println!("{}", result);
|
||||||
|
|
||||||
|
// Part 2
|
||||||
|
let result = count_with_directional_seats(&layout);
|
||||||
|
println!("{}", result);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
type Layout = Array2<Seating>;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
enum Seating {
|
||||||
|
Occupied,
|
||||||
|
Empty,
|
||||||
|
Floor,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Seating {
|
||||||
|
fn new(symbol: char) -> Result<Self, String> {
|
||||||
|
match symbol {
|
||||||
|
'#' => Ok(Seating::Occupied),
|
||||||
|
'L' => Ok(Seating::Empty),
|
||||||
|
'.' => Ok(Seating::Floor),
|
||||||
|
rubbish => Err(format!("Found some rubbish on the floor, area must be clean to conserve human behavior: {}", rubbish))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_layout(input: &str) -> Result<Layout, String> {
|
||||||
|
let (i, j) = (
|
||||||
|
input.lines().count(),
|
||||||
|
input.lines().next().ok_or("Waiting room too small")?.len(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Padding the input data so that we can later comfortably produce
|
||||||
|
// a convolution
|
||||||
|
|
||||||
|
let grid = input
|
||||||
|
.lines()
|
||||||
|
.flat_map(|line| {
|
||||||
|
iter::once(Ok(Seating::Floor))
|
||||||
|
.chain(line.chars().map(Seating::new))
|
||||||
|
.chain(iter::once(Ok(Seating::Floor)))
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<Seating>, String>>()?;
|
||||||
|
|
||||||
|
Array2::from_shape_vec((i, j), grid)
|
||||||
|
.map_err(|_| "Non-square waiting rooms don't exist".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn count_with_neighboring_seats(layout: &Layout) -> usize {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn count_with_directional_seats(layout: &Layout) -> usize {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use indoc::indoc;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_simple() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let input = indoc!(
|
||||||
|
"L.LL.LL.LL
|
||||||
|
LLLLLLL.LL
|
||||||
|
L.L.L..L..
|
||||||
|
LLLL.LL.LL
|
||||||
|
L.LL.LL.LL
|
||||||
|
L.LLLLL.LL
|
||||||
|
..L.L.....
|
||||||
|
LLLLLLLLLL
|
||||||
|
L.LLLLLL.L
|
||||||
|
L.LLLLL.LL
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
|
let layout = parse_layout(&input)?;
|
||||||
|
let result = count_with_neighboring_seats(&layout);
|
||||||
|
|
||||||
|
assert_eq!(result, 37);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_simple2() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let input = indoc!(
|
||||||
|
"L.LL.LL.LL
|
||||||
|
LLLLLLL.LL
|
||||||
|
L.L.L..L..
|
||||||
|
LLLL.LL.LL
|
||||||
|
L.LL.LL.LL
|
||||||
|
L.LLLLL.LL
|
||||||
|
..L.L.....
|
||||||
|
LLLLLLLLLL
|
||||||
|
L.LLLLLL.L
|
||||||
|
L.LLLLL.LL
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
|
let layout = parse_layout(&input)?;
|
||||||
|
let result = count_with_directional_seats(&layout);
|
||||||
|
|
||||||
|
assert_eq!(result, 37);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue