Created
November 1, 2016 08:31
-
-
Save CaseyLeask/5ae86ca8d3037b3d807d1537ccb4ae6c 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; | |
| use std::io::BufRead; | |
| fn main() { | |
| let stdin = io::stdin(); | |
| let lines: Vec<std::string::String> = stdin.lock().lines().map(|l| l.unwrap()).collect(); | |
| let trimmed = lines[0].trim(); | |
| let mut count = 0; | |
| match trimmed.parse::<usize>() { | |
| Ok(i) => count = i, | |
| Err(..) => println!("this was not an integer: {}", trimmed) | |
| }; | |
| let contacts = (1..).take(count).map(|i| { | |
| let words: Vec<&str> = lines[i].trim().split_whitespace().collect(); | |
| let (name, email) = (words[0], words[1]); | |
| (name, email) | |
| }); | |
| let gmail_contacts = contacts.filter(|contact| contact.1.ends_with("@gmail.com")); | |
| let mut names = gmail_contacts.map(|contact| contact.0).collect::<Vec<&str>>(); | |
| names.sort(); | |
| for name in names { | |
| println!("{}", name); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment