mirror of
https://github.com/kristoferssolo/Advent-of-Code.git
synced 2025-10-21 18:00:35 +00:00
Merge branch 'day-15'
This commit is contained in:
commit
6bda6e80c7
10
2023/day-15/Cargo.toml
Normal file
10
2023/day-15/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "day-15"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
color-eyre.workspace = true
|
||||||
|
itertools.workspace = true
|
||||||
1
2023/day-15/input.txt
Normal file
1
2023/day-15/input.txt
Normal file
File diff suppressed because one or more lines are too long
9
2023/day-15/src/bin/part1.rs
Normal file
9
2023/day-15/src/bin/part1.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
use color_eyre::Result;
|
||||||
|
use day_15::part1::process;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
let file = include_str!("../../input.txt");
|
||||||
|
let result = process(file)?;
|
||||||
|
println!("{}", result);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
9
2023/day-15/src/bin/part2.rs
Normal file
9
2023/day-15/src/bin/part2.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
use color_eyre::Result;
|
||||||
|
use day_15::part2::process;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
let file = include_str!("../../input.txt");
|
||||||
|
let result = process(file)?;
|
||||||
|
println!("{}", result);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
2
2023/day-15/src/lib.rs
Normal file
2
2023/day-15/src/lib.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pub mod part1;
|
||||||
|
pub mod part2;
|
||||||
24
2023/day-15/src/part1.rs
Normal file
24
2023/day-15/src/part1.rs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
use color_eyre::Result;
|
||||||
|
|
||||||
|
pub fn process(input: &str) -> Result<usize> {
|
||||||
|
let num = input
|
||||||
|
.split(",")
|
||||||
|
.map(|hash| {
|
||||||
|
hash.chars()
|
||||||
|
.fold(0, |acc, next_char| (acc + (next_char as usize)) * 17 % 256)
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
Ok(num)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_process() -> Result<()> {
|
||||||
|
let input = "rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7";
|
||||||
|
assert_eq!(1320, process(input)?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
19
2023/day-15/src/part2.rs
Normal file
19
2023/day-15/src/part2.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
use color_eyre::Result;
|
||||||
|
|
||||||
|
pub fn process(input: &str) -> Result<usize> {
|
||||||
|
todo!("day xx - part 2");
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_process() -> Result<()> {
|
||||||
|
let input = "";
|
||||||
|
todo!("haven't built test yet");
|
||||||
|
assert_eq!(0, process(input)?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user