diff options
author | alyx <alyx@aleteoryx.me> | 2023-11-20 17:12:15 -0500 |
---|---|---|
committer | alyx <alyx@aleteoryx.me> | 2023-11-20 17:12:15 -0500 |
commit | ccf1a5828fc26a82545c7accf1ce7916daa08a2d (patch) | |
tree | 2428c1374e8f9bcbfd00c8090606f4781d083401 /2015/rs/src/two.rs | |
parent | 4810e24657a5931ea79be3fc3ee3e108fe40282e (diff) | |
download | adventofcode-ccf1a5828fc26a82545c7accf1ce7916daa08a2d.tar.gz adventofcode-ccf1a5828fc26a82545c7accf1ce7916daa08a2d.tar.bz2 adventofcode-ccf1a5828fc26a82545c7accf1ce7916daa08a2d.zip |
Reorganize using workspaces
Diffstat (limited to '2015/rs/src/two.rs')
-rw-r--r-- | 2015/rs/src/two.rs | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/2015/rs/src/two.rs b/2015/rs/src/two.rs deleted file mode 100644 index 572c556..0000000 --- a/2015/rs/src/two.rs +++ /dev/null @@ -1,31 +0,0 @@ -static INPUT: &'static str = include_str!("two.txt"); - -fn main() { - let valueified = INPUT - .split('\n') - .filter(|s| !s.is_empty()) - .map(|line| { - let mut nums = line - .split('x') - .map(str::parse::<u32>) - .map(Result::unwrap); - (nums.next().unwrap(), nums.next().unwrap(), nums.next().unwrap()) - }); - - let final_area: u32 = valueified.clone() - .map(|(w, l, h)| { - let sides = [w*h, l*w, h*l]; - sides.into_iter().min().unwrap() + sides.into_iter().sum::<u32>() * 2 - }) - .sum(); - println!("Final area: {final_area}"); - - let ribbon_length: u32 = valueified - .map(|(w, l, h)| { - let mut nums = [w, l, h]; - nums.sort(); - (nums[0] + nums[1]) * 2 + (w * l * h) - }) - .sum(); - println!("Ribbon length: {ribbon_length}"); -} |