refactoring 01/01

This commit is contained in:
Markus Dieckmann 2023-12-04 11:26:45 +01:00
parent 513448bbbd
commit ca7dd3dad3

View File

@ -7,13 +7,12 @@ fn main() {
fn process(input: &str) -> i32 { fn process(input: &str) -> i32 {
let lines: i32 = input let lines: i32 = input
.lines() .lines()
.into_iter()
.map(|line| { .map(|line| {
let line_vec = line let line_vec = line
.chars() .chars()
.filter(|c| c.is_digit(10)) .filter(|c| c.is_ascii_digit())
.collect::<Vec<char>>(); .collect::<Vec<char>>();
let first = line_vec.clone().into_iter().nth(0); let first = line_vec.clone().into_iter().next();
let last = line_vec.clone().into_iter().nth_back(0); let last = line_vec.clone().into_iter().nth_back(0);
[first.unwrap(), last.unwrap()].into_iter().collect() [first.unwrap(), last.unwrap()].into_iter().collect()
}) })