Skip to content

Instantly share code, notes, and snippets.

@crumblingstatue
Created December 4, 2016 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crumblingstatue/75a4112ddb18a03ce6829bd5ebec4e10 to your computer and use it in GitHub Desktop.
Save crumblingstatue/75a4112ddb18a03ce6829bd5ebec4e10 to your computer and use it in GitHub Desktop.
#![feature(conservative_impl_trait)]
fn parse<'a>(input: &'a str) -> impl 'a + Iterator<Item = (u32, u32, u32)> {
input.lines().map(|l| {
let mut words = l.split_whitespace();
let mut get = || words.next().unwrap().parse().unwrap();
(get(), get(), get())
})
}
fn main() {
let input = include_str!("../../input/3");
let n_possible = parse(input).filter(|&(a, b, c)| a + b > c && a + c > b && c + b > a).count();
println!("{}", n_possible);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment