Skip to content

Commit

Permalink
feat: create boilerplate for day 1/2024
Browse files Browse the repository at this point in the history
  • Loading branch information
manhunto committed Nov 30, 2024
1 parent 612d5f9 commit e2203ea
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 34 deletions.
Empty file added resources/2024/inputs/.gitkeep
Empty file.
Empty file added resources/2024/outputs/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::aoc::year::Year::Year2024;
use crate::commands::input::download_input;
use crate::commands::output::download_output;
use crate::commands::solve::solve;
use aoc::day_number::DayNumber;
use aoc::puzzle_part::PuzzlePart;
use aoc::year::Year;
use aoc::year::Year::Year2023;
use clap::{Parser, Subcommand};
use dotenv::dotenv;

Expand Down Expand Up @@ -66,7 +66,7 @@ fn main() {
let day_number_option = day_option.map(|d| DayNumber::try_from(d).unwrap());
let day_number: DayNumber = DayNumber::try_from(day_option.unwrap_or(1).to_string()).unwrap();

let year = cli.year.unwrap_or(Year2023);
let year = cli.year.unwrap_or(Year2024);

match command {
Command::Solve { submit_answer } => {
Expand Down
63 changes: 31 additions & 32 deletions src/solutions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use crate::aoc::day_number::DayNumber;
use crate::aoc::year::Year;
use crate::solutions::year2023::day19;
use year2023::{
day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13,
day14, day15, day16, day17, day18, day20, day21, day22, day23, day24, day25,
};

mod year2023;
mod year2024;

pub trait Solution {
fn part_one(&self, input: &str) -> String;
Expand All @@ -17,34 +13,37 @@ pub fn solution(day: DayNumber, year: Year) -> Box<dyn Solution> {
let i: u8 = day.into();

match year {
Year::Year2023 => match i {
1 => Box::new(day01::Day01),
2 => Box::new(day02::Day02),
3 => Box::new(day03::Day03),
4 => Box::new(day04::Day04),
5 => Box::new(day05::Day05),
6 => Box::new(day06::Day06),
7 => Box::new(day07::Day07),
8 => Box::new(day08::Day08),
9 => Box::new(day09::Day09),
10 => Box::new(day10::Day10),
11 => Box::new(day11::Day11),
12 => Box::new(day12::Day12),
13 => Box::new(day13::Day13),
14 => Box::new(day14::Day14),
15 => Box::new(day15::Day15),
16 => Box::new(day16::Day16),
17 => Box::new(day17::Day17),
18 => Box::new(day18::Day18),
19 => Box::new(day19::Day19),
20 => Box::new(day20::Day20),
21 => Box::new(day21::Day21),
22 => Box::new(day22::Day22),
23 => Box::new(day23::Day23),
24 => Box::new(day24::Day24),
25 => Box::new(day25::Day25),
Year::Year2024 => match i {
1 => Box::new(year2024::day01::Day01),
_ => panic!("Day not exist"),
},
Year::Year2024 => todo!("2024 is not implemented yet"),
Year::Year2023 => match i {
1 => Box::new(year2023::day01::Day01),
2 => Box::new(year2023::day02::Day02),
3 => Box::new(year2023::day03::Day03),
4 => Box::new(year2023::day04::Day04),
5 => Box::new(year2023::day05::Day05),
6 => Box::new(year2023::day06::Day06),
7 => Box::new(year2023::day07::Day07),
8 => Box::new(year2023::day08::Day08),
9 => Box::new(year2023::day09::Day09),
10 => Box::new(year2023::day10::Day10),
11 => Box::new(year2023::day11::Day11),
12 => Box::new(year2023::day12::Day12),
13 => Box::new(year2023::day13::Day13),
14 => Box::new(year2023::day14::Day14),
15 => Box::new(year2023::day15::Day15),
16 => Box::new(year2023::day16::Day16),
17 => Box::new(year2023::day17::Day17),
18 => Box::new(year2023::day18::Day18),
19 => Box::new(year2023::day19::Day19),
20 => Box::new(year2023::day20::Day20),
21 => Box::new(year2023::day21::Day21),
22 => Box::new(year2023::day22::Day22),
23 => Box::new(year2023::day23::Day23),
24 => Box::new(year2023::day24::Day24),
25 => Box::new(year2023::day25::Day25),
_ => panic!("Day not exist"),
}
}
}
26 changes: 26 additions & 0 deletions src/solutions/year2024/day01.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use crate::solutions::Solution;

pub struct Day01;

impl Solution for Day01 {
fn part_one(&self, _input: &str) -> String {
String::new()
}

fn part_two(&self, _input: &str) -> String {
String::new()
}
}

#[cfg(test)]
mod tests {
use crate::solutions::year2024::day01::Day01;
use crate::solutions::Solution;

const EXAMPLE: &str = "";

#[test]
fn part_one_example_test() {
assert_eq!("", Day01.part_one(EXAMPLE));
}
}
1 change: 1 addition & 0 deletions src/solutions/year2024/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod day01;

0 comments on commit e2203ea

Please sign in to comment.