-
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
bozdoz
committed
Dec 13, 2023
1 parent
1a53d01
commit 26c9105
Showing
3 changed files
with
104 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "day-13" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
lib = { version = "0.1.0", path = "../lib" } |
Empty file.
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,95 @@ | ||
use std::{time::Instant, fs}; | ||
use lib::get_part; | ||
|
||
/** identify the direction of the reflection, with the col/row */ | ||
enum Reflection { | ||
Horizontal(usize), | ||
Vertical(usize) | ||
} | ||
|
||
enum Item { | ||
Ash, | ||
Rock | ||
} | ||
|
||
struct Pattern { | ||
// uh oh, not going with hashmap | ||
grid: Vec<Vec<Item>> | ||
} | ||
|
||
impl Pattern { | ||
fn new(contents: &str) -> Self { | ||
let lines = contents.lines(); | ||
let mut grid = vec![]; | ||
|
||
// maybe don't need enumerate | ||
for line in lines { | ||
let mut row = vec![]; | ||
for char in line.chars() { | ||
// avoided using a `match` here, since the third option is panic | ||
row.push(if char == '.' { | ||
Item::Ash | ||
} else { | ||
Item::Rock | ||
}); | ||
} | ||
grid.push(row); | ||
} | ||
|
||
Self { grid } | ||
} | ||
|
||
fn find_reflection_point() -> Reflection { | ||
|
||
Reflection::Horizontal(0) | ||
} | ||
} | ||
|
||
fn part_one() -> usize { | ||
0 | ||
} | ||
|
||
fn part_two() -> usize { | ||
0 | ||
} | ||
|
||
fn main() { | ||
let (one, two) = get_part(); | ||
let start = Instant::now(); | ||
let contents = fs::read_to_string("./src/input.txt").unwrap(); | ||
|
||
if one { | ||
let now = Instant::now(); | ||
let ans = part_one(); | ||
println!("Part one: {:?} {:?}", ans, now.elapsed()); | ||
} | ||
|
||
if two { | ||
let now = Instant::now(); | ||
let ans = part_two(); | ||
println!("Part two: {:?} {:?}", ans, now.elapsed()); | ||
} | ||
|
||
println!("Time: {:?}", start.elapsed()) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
const EXAMPLE: &str = include_str!("./example.txt"); | ||
|
||
#[test] | ||
fn test_part_one() { | ||
let ans = part_one(); | ||
|
||
assert_eq!(ans, 0); | ||
} | ||
|
||
#[test] | ||
fn test_part_two() { | ||
let ans = part_two(); | ||
|
||
assert_eq!(ans, 0); | ||
} | ||
} |