|
|
|
|
@ -1,17 +1,20 @@
|
|
|
|
|
|
|
|
|
|
use ::solver_base::solver_base::Solver;
|
|
|
|
|
use ::solver_base::solver_base::{Solver, RunMode};
|
|
|
|
|
use utils::utils;
|
|
|
|
|
|
|
|
|
|
pub struct Day1
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
run_mode: RunMode,
|
|
|
|
|
do_debug_prints: bool,
|
|
|
|
|
data_a: Vec<i32>,
|
|
|
|
|
data_b: Vec<i32>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Day1
|
|
|
|
|
{
|
|
|
|
|
pub fn new() -> Day1
|
|
|
|
|
{
|
|
|
|
|
Day1 { }
|
|
|
|
|
Day1 { run_mode: RunMode::TestCase, do_debug_prints: false, data_a: vec![], data_b: vec![] }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -27,13 +30,52 @@ impl Solver for Day1
|
|
|
|
|
println!("DATA: {}", data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn init(self: &mut Self)
|
|
|
|
|
fn init(self: &mut Self, run_mode: RunMode, enable_debug_prints: bool)
|
|
|
|
|
{
|
|
|
|
|
todo!()
|
|
|
|
|
self.run_mode = run_mode;
|
|
|
|
|
self.do_debug_prints = enable_debug_prints;
|
|
|
|
|
|
|
|
|
|
let dir = utils::get_working_dir();
|
|
|
|
|
let data_filename =
|
|
|
|
|
match self.run_mode
|
|
|
|
|
{
|
|
|
|
|
RunMode::TestCase => format!("{}/data/test_case", dir),
|
|
|
|
|
RunMode::FirstCase => format!("{}/data/input", dir),
|
|
|
|
|
RunMode::SecondCase => format!("{}/data/input_second", dir),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = utils::load_data(&data_filename);
|
|
|
|
|
|
|
|
|
|
// Split the data and convert to i32 values
|
|
|
|
|
let data: Vec<i32> = data.split_ascii_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();
|
|
|
|
|
|
|
|
|
|
// Split by column
|
|
|
|
|
for (i, d) in data.iter().enumerate()
|
|
|
|
|
{
|
|
|
|
|
// if i is even
|
|
|
|
|
if i % 2 < 1
|
|
|
|
|
{
|
|
|
|
|
self.data_a.push(*d)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
self.data_b.push(*d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if self.do_debug_prints
|
|
|
|
|
{
|
|
|
|
|
println!("Input data processed:\n\tdata_a: {:#?}\n\tdata_b: {:#?}", self.data_a, self.data_b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn solve(self: &mut Self) -> String
|
|
|
|
|
{
|
|
|
|
|
todo!()
|
|
|
|
|
// TODO: Day1::solve
|
|
|
|
|
println!("Day 1 solve not implemented yet.");
|
|
|
|
|
"NO RESULTS".to_string()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|