Prefer this syntax for only taking the second part of a split
This commit is contained in:
parent
a5c515f64a
commit
408473c50a
|
@ -88,7 +88,7 @@ impl aoc::Solver for Day {
|
||||||
|
|
||||||
// If valid, get the id and add it to the sum
|
// If valid, get the id and add it to the sum
|
||||||
if valid {
|
if valid {
|
||||||
let (_, id) = game.split_once(' ').unwrap();
|
let id = game.split_once(' ').unwrap().1;
|
||||||
let id: usize = id.parse().unwrap();
|
let id: usize = id.parse().unwrap();
|
||||||
Some(id)
|
Some(id)
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,7 +107,7 @@ impl aoc::Solver for Day {
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| {
|
.map(|line| {
|
||||||
// Split the game id from the actual game played
|
// Split the game id from the actual game played
|
||||||
let (_, line) = line.split_once(": ").unwrap();
|
let line = line.split_once(": ").unwrap().1;
|
||||||
|
|
||||||
// Get the required minimum amount for each color
|
// Get the required minimum amount for each color
|
||||||
let required = line.split(", ").fold((0, 0, 0), |acc, entry| {
|
let required = line.split(", ").fold((0, 0, 0), |acc, entry| {
|
||||||
|
|
|
@ -61,9 +61,10 @@ impl aoc::Solver for Day {
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| {
|
.map(|line| {
|
||||||
// Get rid of the first part
|
// Get rid of the first part
|
||||||
let (_, line) = line
|
let line = line
|
||||||
.split_once(": ")
|
.split_once(": ")
|
||||||
.expect("Input should be formatted properly");
|
.expect("Input should be formatted properly")
|
||||||
|
.1;
|
||||||
|
|
||||||
// Seperate the winning numbers and numbers we have
|
// Seperate the winning numbers and numbers we have
|
||||||
let (winning, numbers) = line
|
let (winning, numbers) = line
|
||||||
|
@ -96,9 +97,10 @@ impl aoc::Solver for Day {
|
||||||
|
|
||||||
input.lines().enumerate().for_each(|(i, line)| {
|
input.lines().enumerate().for_each(|(i, line)| {
|
||||||
// Get rid of the first part
|
// Get rid of the first part
|
||||||
let (_, line) = line
|
let line = line
|
||||||
.split_once(": ")
|
.split_once(": ")
|
||||||
.expect("Input should be formatted properly");
|
.expect("Input should be formatted properly")
|
||||||
|
.1;
|
||||||
|
|
||||||
// Seperate the winning numbers and numbers we have
|
// Seperate the winning numbers and numbers we have
|
||||||
let (winning, numbers) = line
|
let (winning, numbers) = line
|
||||||
|
|
Loading…
Reference in New Issue
Block a user