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

View File

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