|
|
@ -1,12 +1,21 @@
|
|
|
|
pub fn solve(input: &str) -> String {
|
|
|
|
pub fn solve(input: &str) -> String {
|
|
|
|
let parsed = input.split_whitespace()
|
|
|
|
let parsed = input.lines()
|
|
|
|
.map(str::parse)
|
|
|
|
.map(|line| {
|
|
|
|
.collect::<Result<Vec<usize>, _>>()
|
|
|
|
line.split_whitespace().map(str::parse).collect::<Result<Vec<usize>, _>>()
|
|
|
|
.expect("unable to parse input");
|
|
|
|
})
|
|
|
|
|
|
|
|
.collect::<Result<Vec<_>, _>>()
|
|
|
|
|
|
|
|
.expect("couldn't parse input");
|
|
|
|
let count = parsed.chunks(3)
|
|
|
|
let count = parsed.chunks(3)
|
|
|
|
.map(|w| Triangle(w[0], w[1], w[2]))
|
|
|
|
.flat_map(|chunk| {
|
|
|
|
|
|
|
|
vec![
|
|
|
|
|
|
|
|
Triangle(chunk[0][0], chunk[1][0], chunk[2][0]),
|
|
|
|
|
|
|
|
Triangle(chunk[0][1], chunk[1][1], chunk[2][1]),
|
|
|
|
|
|
|
|
Triangle(chunk[0][2], chunk[1][2], chunk[2][2]),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
})
|
|
|
|
.filter(Triangle::is_valid)
|
|
|
|
.filter(Triangle::is_valid)
|
|
|
|
.count();
|
|
|
|
.count();
|
|
|
|
|
|
|
|
|
|
|
|
count.to_string()
|
|
|
|
count.to_string()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|