2018: day05: move logic to collapse fn

This commit is contained in:
Antoine Martin 2019-11-22 17:26:02 +01:00
parent d17e26540f
commit 7ca4504295

View file

@ -12,7 +12,7 @@ fn same_type(a: char, b: char) -> bool {
a.to_ascii_lowercase() == b.to_ascii_lowercase()
}
fn part1(input: &str) -> Result<usize> {
fn collapse(input: &str) -> String {
let mut res = String::with_capacity(input.len());
// tracks last character of string
@ -42,6 +42,11 @@ fn part1(input: &str) -> Result<usize> {
res.push(c);
}
res
}
fn part1(input: &str) -> Result<usize> {
let res = collapse(input);
Ok(res.len())
}