add day 17
This commit is contained in:
Generated
+25
@@ -0,0 +1,25 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day17"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"itertools",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "day17"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
itertools = "0.15.0"
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
11
|
||||||
|
30
|
||||||
|
47
|
||||||
|
31
|
||||||
|
32
|
||||||
|
36
|
||||||
|
3
|
||||||
|
1
|
||||||
|
5
|
||||||
|
3
|
||||||
|
32
|
||||||
|
36
|
||||||
|
15
|
||||||
|
11
|
||||||
|
46
|
||||||
|
26
|
||||||
|
28
|
||||||
|
1
|
||||||
|
19
|
||||||
|
3
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let data: Vec<u64> = std::fs::read_to_string("input.txt")
|
||||||
|
.unwrap()
|
||||||
|
.lines()
|
||||||
|
.map(|s| s.parse().unwrap())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let mut result = 0;
|
||||||
|
for i in 1..=20 {
|
||||||
|
let c = data
|
||||||
|
.iter()
|
||||||
|
.combinations(i)
|
||||||
|
.map(|c| c.iter().cloned().sum::<u64>())
|
||||||
|
.filter(|s| *s == 150)
|
||||||
|
.count();
|
||||||
|
result += c;
|
||||||
|
println!("{i} -> {c}");
|
||||||
|
}
|
||||||
|
println!("{result}");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user