Created
August 12, 2015 11:22
-
-
Save tomgco/4e4928e2df4b330cf9c1 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::prelude::*; | |
fn main() { | |
let mut grow: Vec<i64> = vec![0,0,0,0,0,0,0,0,0,0]; | |
let stdin = io::stdin(); | |
// let writer = io::stdout(); | |
for line in stdin.lock().lines() { | |
match line { | |
Ok(line) => { | |
let item = line.split(",").nth(2); | |
match item { | |
Some(action_type) => { | |
let i: Option<i32> = action_type.trim().parse::<i32>().ok(); | |
match i { | |
Some(i) => { | |
let index = i as usize; | |
let val = grow.get_mut(index-1); | |
match val { | |
Some(inc) => *inc += 1, | |
None => panic!("More than expected") | |
} | |
}, | |
None => panic!("Sad Times") | |
} | |
} | |
None => panic!("Oh dear ") | |
} | |
// print!("{}", line.split(",").collect()[2]), | |
} | |
Err(err) => panic!("I/O error {}", err), | |
} | |
} | |
print!("{:?}", grow); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment