Update formatting
This commit is contained in:
@@ -22,7 +22,10 @@ impl Solver for Cafeteria {
|
||||
.map_while(|x| x.ok().filter(|s| !s.is_empty()))
|
||||
{
|
||||
// TODO: This code should move into new common::interval::MultiInterval struct.
|
||||
let values: Vec<u64> = line.split(Self::INTERVAL_SPLIT_CHAR).map_while(|s| s.parse().ok()).collect();
|
||||
let values: Vec<u64> = line
|
||||
.split(Self::INTERVAL_SPLIT_CHAR)
|
||||
.map_while(|s| s.parse().ok())
|
||||
.collect();
|
||||
let mut interval = Interval::new(values[0], values[1]);
|
||||
|
||||
let mut to_delete = Vec::new();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::solvers::Solver;
|
||||
use grid::*;
|
||||
use grid::Grid;
|
||||
use std::io::BufRead;
|
||||
|
||||
pub struct PrintingDepartment {}
|
||||
@@ -15,7 +15,11 @@ impl Solver for PrintingDepartment {
|
||||
fn process_data<R: BufRead>(&self, reader: R) -> (u64, u64) {
|
||||
let mut grid = Grid::new(0, 0);
|
||||
for line in reader.lines().map_while(Result::ok) {
|
||||
grid.push_row(line.bytes().map(|c| c == Self::PAPER_ROLL_CHAR as u8).collect());
|
||||
grid.push_row(
|
||||
line.bytes()
|
||||
.map(|c| c == Self::PAPER_ROLL_CHAR as u8)
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
|
||||
let mut part1 = 0;
|
||||
|
||||
@@ -16,7 +16,10 @@ impl Solver for TrashCompactor {
|
||||
let mut part1 = 0;
|
||||
let mut grid = Grid::new(0, 0);
|
||||
for line in reader.lines().map_while(Result::ok) {
|
||||
let v: Vec<&str> = line.split(Self::NUMBER_SPLIT_CHAR).filter(|s| !s.is_empty()).collect();
|
||||
let v: Vec<&str> = line
|
||||
.split(Self::NUMBER_SPLIT_CHAR)
|
||||
.filter(|s| !s.is_empty())
|
||||
.collect();
|
||||
match v[0].parse::<u32>() {
|
||||
Ok(_) => grid.push_row(v.iter().map(|n| n.parse::<u64>().unwrap()).collect()),
|
||||
Err(_) => {
|
||||
|
||||
+4
-1
@@ -45,6 +45,9 @@ fn playground() {
|
||||
fn movie_theater() {
|
||||
assert_eq!(
|
||||
Ok((4781235324, 0)),
|
||||
solvers::run_solver(solvers::movie_theater::MovieTheater {}, &solvers::DATA_PATHS)
|
||||
solvers::run_solver(
|
||||
solvers::movie_theater::MovieTheater {},
|
||||
&solvers::DATA_PATHS
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user