Created
May 5, 2016 13:42
-
-
Save Yasushi/c09326db45c273cdb7704cc3b24e1d37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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