Small changes.

This commit is contained in:
2016-12-23 22:15:03 +01:00
parent df49cc1866
commit 8c5ec3fe9d
2 changed files with 10 additions and 11 deletions

View File

@@ -22,28 +22,27 @@ fn main() {
let count_v = input
.chunks(3)
.flat_map(|x| {
x[0]
.iter()
.zip(&x[1])
.zip(&x[2])
.flat_map(|rows| {
rows[0].iter()
.zip(&rows[1])
.zip(&rows[2])
.map(|((x, y), z)| [x, y, z])
})
.filter(|x| is_triangle(*x[0], *x[1], *x[2]))
.count();
println!("count={}", count_h);
println!("count={}", count_v);
println!("count_h={}", count_h);
println!("count_v={}", count_v);
}
fn is_triangle(a: i32, b: i32, c: i32) -> bool {
pub fn is_triangle(a: i32, b: i32, c: i32) -> bool {
a + b > c && b + c > a && c + a > b
}
#[cfg(test)]
mod tests {
use super::is_triangle;
use super::*;
#[test]
fn example_01() {