Skip to content

Commit

Permalink
Merge pull request #85 from creberust/84-add-aoc-2023-edition
Browse files Browse the repository at this point in the history
chore: add aoc edition 2023
  • Loading branch information
creberust authored Dec 3, 2023
2 parents f03b47b + 8573d29 commit 49dc6c2
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["aoc", "aoc-2022", "common"]
members = ["aoc", "aoc-2022", "aoc-2023", "common"]
resolver = "2"

[workspace.package]
authors = ["creberust"]
Expand Down
13 changes: 13 additions & 0 deletions aoc-2023/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "aoc-2023"
version = "0.1.0"
edition = "2021"
authors.workspace = true
readme.workspace = true
repository.workspace = true
license-file.workspace = true
keywords.workspace = true
publish.workspace = true

[dependencies]
common = { version = "0.1.0", path = "../common" }
7 changes: 7 additions & 0 deletions aoc-2023/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Event for the Advent of Code 2023.
use common::{Event, Year};

pub fn event() -> Event {
Event::new(Year::from(2023), [].into_iter())
}
1 change: 1 addition & 0 deletions aoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ publish.workspace = true
[dependencies]
aoc-2015 = { version = "0", path = "../aoc-2015" }
aoc-2022 = { version = "0", path = "../aoc-2022" }
aoc-2023 = { version = "0", path = "../aoc-2023" }
clap = { version = "4.1.8", features = ["derive"] }
common = { version = "0.1.0", path = "../common" }
log.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion aoc/src/aoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ impl AdventOfCode {
events: [
(Year::from(2015), aoc_2015::event()),
(Year::from(2022), aoc_2022::event()),
(Year::from(2023), aoc_2023::event()),
]
.into(),
}
Expand All @@ -34,7 +35,7 @@ impl AdventOfCode {
for event in self.events.values() {
println!("{}", event);

self.solve_all_days(&event)
self.solve_all_days(event)
}
}

Expand Down
2 changes: 1 addition & 1 deletion aoc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Cli {
/// The advent of code event for the given year.
///
/// By default, every year will be solved.
#[arg(value_parser = value_parser!(u16).range(2015..=2022))]
#[arg(value_parser = value_parser!(u16).range(2015..=2023))]
pub year: Option<u16>,

/// The day from the selected advent of code event.
Expand Down
2 changes: 1 addition & 1 deletion common/src/day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Day {

impl From<u8> for Day {
fn from(value: u8) -> Self {
if value < Self::MIN || value > Self::MAX {
if !(Self::MIN..=Self::MAX).contains(&value) {
panic!(
"Invalid value for Day: {} ∉ [{}, {}]",
value,
Expand Down
4 changes: 2 additions & 2 deletions common/src/year.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Year {
/// The minimum year of the Advent of Code event.
const MIN: u16 = 2015;
/// The maximum recent year of the Advent of Code event.
const MAX: u16 = 2022;
const MAX: u16 = 2023;

/// The first year of the Advent of Code event.
pub const FIRST: Year = Year(Self::MIN);
Expand All @@ -27,7 +27,7 @@ impl Year {

impl From<u16> for Year {
fn from(value: u16) -> Self {
if value < Self::MIN || value > Self::MAX {
if !(Self::MIN..=Self::MAX).contains(&value) {
panic!(
"Invalid value for Year: {} ∉ [{}, {}]",
value,
Expand Down

0 comments on commit 49dc6c2

Please sign in to comment.