Use .lines() instead of .split()

This commit is contained in:
Dreaded_X 2022-12-02 21:09:31 +01:00
parent 0ce2d32c0a
commit cdaf5ebc6f
Signed by: Dreaded_X
GPG Key ID: 76BDEC4E165D8AD9
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ impl aoc::Solver for Day {
fn part1(input: &str) -> u32 {
input.split("\n\n")
.map(|elf| elf.split("\n")
.map(|elf| elf.lines()
.flat_map(|snack| snack.parse::<u32>())
.sum())
.max()
@ -38,7 +38,7 @@ impl aoc::Solver for Day {
fn part2(input: &str) -> u32 {
let mut elfs: Vec<u32> = input.split("\n\n")
.map(|elf| elf.split("\n")
.map(|elf| elf.lines()
.flat_map(|snack| snack.parse::<u32>())
.sum())
.collect();

View File

@ -103,7 +103,7 @@ impl aoc::Solver for Day {
}
fn part1(input: &str) -> u32 {
input.split("\n")
input.lines()
.filter(|round| round.len() > 0)
.map(round_to_letters)
.map(|(a, b)| (Hand::from(a), Hand::from(b)))
@ -112,7 +112,7 @@ impl aoc::Solver for Day {
}
fn part2(input: &str) -> u32 {
input.split("\n")
input.lines()
.filter(|round| round.len() > 0)
.map(round_to_letters)
.map(|(a, b)| (Hand::from(a), b))