21 lines
565 B
Rust
21 lines
565 B
Rust
use std::io::{self, Read};
|
|
|
|
fn main() {
|
|
let mut buf = String::new();
|
|
io::stdin().read_to_string(&mut buf).unwrap();
|
|
|
|
let lines: Vec<String> = buf.lines().map(ToOwned::to_owned).collect();
|
|
|
|
let answer: Result<i32, _> = lines
|
|
.into_iter()
|
|
.map(|l| l.chars().filter(char::is_ascii_digit).collect())
|
|
.map(|s: String| [s.chars().next().unwrap(), s.chars().last().unwrap()].to_owned())
|
|
.map(String::from_iter)
|
|
.map(|s| s.parse::<i32>())
|
|
.sum();
|
|
|
|
let answer = answer.unwrap();
|
|
|
|
print!("{answer}");
|
|
}
|