refactor 01/02

This commit is contained in:
Markus Dieckmann 2023-12-04 11:28:12 +01:00
parent ca7dd3dad3
commit d126d69669

View File

@ -9,15 +9,14 @@ 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(replacer)
.map(|x| replacer(x))
.map(|line| { .map(|line| {
println!("{line}"); println!("{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()
}) })