-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
668 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["day01", "day02", "day03", "day04", "day05", "day06", "day07", "day08", "day09"] | ||
members = ["day01", "day02", "day03", "day04", "day05", "day06", "day07", "day08", "day09", "day10"] | ||
|
||
[workspace.package] | ||
authors = ["David Oberacker <[email protected]>"] | ||
|
@@ -15,6 +15,7 @@ rayon = "1.8.0" | |
num = "0.4" | ||
itertools = "0.12.0" | ||
ranges = "0.3.3" | ||
ndarray = "0.15.6" | ||
|
||
[profile.release] | ||
incremental = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "day10" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
description.workspace = true | ||
publish.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
name = "day10" | ||
path = "src/lib.rs" | ||
|
||
[[bin]] | ||
name = "day10_part1" | ||
|
||
[[bin]] | ||
name = "day10_part2" | ||
|
||
[dependencies] | ||
ndarray.workspace = true | ||
anyhow.workspace = true |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
..... | ||
.S-7. | ||
.|.|. | ||
.L-J. | ||
..... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-L|F7 | ||
7S-7| | ||
L|7|| | ||
-L-J| | ||
L|-JF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
7-F7- | ||
.FJ|7 | ||
SJLL7 | ||
|F--J | ||
LJ.LJ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
........... | ||
.S-------7. | ||
.|F-----7|. | ||
.||.....||. | ||
.||.....||. | ||
.|L-7.F-J|. | ||
.|..|.|..|. | ||
.L--J.L--J. | ||
........... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.F----7F7F7F7F-7.... | ||
.|F--7||||||||FJ.... | ||
.||.FJ||||||||L7.... | ||
FJL7L7LJLJ||LJ.L-7.. | ||
L--J.L7...LJS7F-7L7. | ||
....F-J..F7FJ|L7L7L7 | ||
....L7.F7||L7|.L7L7| | ||
.....|FJLJ|FJ|F7|.LJ | ||
....FJL-7.||.||||... | ||
....L---J.LJ.LJLJ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FF7FSF7F7F7F7F7F---7 | ||
L|LJ||||||||||||F--J | ||
FL-7LJLJ||||||LJL-77 | ||
F--JF--7||LJLJ7F7FJ- | ||
L---JF-JLJ.||-FJLJJ7 | ||
|F|F-JF---7F7-L7L|7| | ||
|FFJF7L7F-JF7|JL---7 | ||
7-L-JL7||F7|L7F-7F7| | ||
L.L7LFJ|||||FJL7||LJ | ||
L7JLJL-JLJLJL--JLJ.L |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,55 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
use std::time::Instant; | ||
use anyhow::Result; | ||
use day10::{get_farthest_tile_in_loop_distance, parse_input}; | ||
|
||
fn main() -> Result<()>{ | ||
let input = include_str!("../../resources/input.txt"); | ||
let now = Instant::now(); | ||
let tiles = parse_input(input)?; | ||
println!("{}", tiles); | ||
|
||
let result = get_farthest_tile_in_loop_distance(&tiles)?; | ||
let elapsed = now.elapsed(); | ||
println!("Result: {}, Elapsed: {:?}", result, elapsed); | ||
Ok(()) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use day10::get_farthest_tile_in_loop_distance; | ||
use super::*; | ||
|
||
#[test] | ||
fn run_test_input01() -> Result<()>{ | ||
|
||
let input = include_str!("../../resources/test_input01.txt"); | ||
let tiles = parse_input(input)?; | ||
println!("{}", tiles); | ||
let result = get_farthest_tile_in_loop_distance(&tiles)?; | ||
assert_eq!(result, 4); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn run_test_input02() -> Result<()>{ | ||
|
||
let input = include_str!("../../resources/test_input02.txt"); | ||
let tiles = parse_input(input)?; | ||
println!("{}", tiles); | ||
let result = get_farthest_tile_in_loop_distance(&tiles)?; | ||
assert_eq!(result, 4); | ||
Ok(()) | ||
} | ||
|
||
|
||
#[test] | ||
fn run_test_input03() -> Result<()>{ | ||
|
||
let input = include_str!("../../resources/test_input03.txt"); | ||
let tiles = parse_input(input)?; | ||
println!("{}", tiles); | ||
let result = get_farthest_tile_in_loop_distance(&tiles)?; | ||
assert_eq!(result, 8); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
use std::time::Instant; | ||
use anyhow::Result; | ||
use day10::{get_encased_cells_count, parse_input}; | ||
|
||
fn main() -> Result<()>{ | ||
let input = include_str!("../../resources/input.txt"); | ||
let now = Instant::now(); | ||
let tiles = parse_input(input)?; | ||
let result = get_encased_cells_count(&tiles)?; | ||
let elapsed = now.elapsed(); | ||
println!("Result: {}, Elapsed: {:?}", result, elapsed); | ||
Ok(()) | ||
} | ||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn run_test_input04() -> Result<()>{ | ||
|
||
let input = include_str!("../../resources/test_input04.txt"); | ||
let tiles = parse_input(input)?; | ||
let result = get_encased_cells_count(&tiles)?; | ||
assert_eq!(result, 4); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn run_test_input05() -> Result<()>{ | ||
|
||
let input = include_str!("../../resources/test_input05.txt"); | ||
let tiles = parse_input(input)?; | ||
let result = get_encased_cells_count(&tiles)?; | ||
assert_eq!(result, 8); | ||
Ok(()) | ||
} | ||
|
||
|
||
#[test] | ||
fn run_test_input06() -> Result<()>{ | ||
|
||
let input = include_str!("../../resources/test_input06.txt"); | ||
let tiles = parse_input(input)?; | ||
let result = get_encased_cells_count(&tiles)?; | ||
assert_eq!(result, 10); | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.