Skip to content

Instantly share code, notes, and snippets.

@Yasushi
Created May 5, 2016 13:42
Show Gist options
  • Select an option

  • Save Yasushi/c09326db45c273cdb7704cc3b24e1d37 to your computer and use it in GitHub Desktop.

Select an option

Save Yasushi/c09326db45c273cdb7704cc3b24e1d37 to your computer and use it in GitHub Desktop.
use std::io::BufRead;
use std::io;
pub fn count_entry<R: BufRead>(input: R) -> usize {
input.lines()
.flat_map(|r| r.ok())
.filter(|l| !l.starts_with(";;"))
.flat_map(|l| l.split("/[").next())
.map(|l| l.trim_right_matches("/").split("/").count() - 1 )
.fold(0, |a, i| a + i)
}
pub fn main() {
let stdin = io::stdin();
println!("{} candidate(s)", count_entry(stdin.lock()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment