use aoc crate for common stuff
This commit is contained in:
parent
907e883d48
commit
64410f0042
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -1,14 +1,27 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "aoc"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aoc2015"
|
name = "aoc2015"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"aoc 0.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aoc2018"
|
name = "aoc2018"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"aoc 0.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aoc2019"
|
name = "aoc2019"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"aoc 0.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"aoc",
|
||||||
"aoc2015",
|
"aoc2015",
|
||||||
"aoc2018",
|
"aoc2018",
|
||||||
"aoc2019",
|
"aoc2019",
|
||||||
|
|
9
aoc/Cargo.toml
Normal file
9
aoc/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "aoc"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Antoine Martin <antoine97.martin@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
6
aoc/src/lib.rs
Normal file
6
aoc/src/lib.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! err {
|
||||||
|
($($string:expr),+) => (Box::<dyn std::error::Error>::from(format!($($string),+)))
|
||||||
|
}
|
|
@ -7,3 +7,5 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
aoc = { path = "../aoc" }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::err;
|
use aoc::err;
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day01.txt");
|
const INPUT: &str = include_str!("../input/day01.txt");
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1 @@
|
||||||
pub mod day01;
|
pub mod day01;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! err {
|
|
||||||
($($string:expr),+) => (Box::<dyn std::error::Error>::from(format!($($string),+)))
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use aoc2015::day01;
|
use aoc::Result;
|
||||||
|
|
||||||
use aoc2015::Result;
|
use aoc2015::day01;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let days: &[fn() -> Result<()>] = &[day01::run];
|
let days: &[fn() -> Result<()>] = &[day01::run];
|
||||||
|
|
|
@ -7,3 +7,5 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
aoc = { path = "../aoc" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day01.txt");
|
const INPUT: &str = include_str!("../input/day01.txt");
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day02.txt");
|
const INPUT: &str = include_str!("../input/day02.txt");
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ use std::collections::HashSet;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use super::err;
|
use aoc::err;
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day03.txt");
|
const INPUT: &str = include_str!("../input/day03.txt");
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use super::err;
|
use aoc::err;
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day04.txt");
|
const INPUT: &str = include_str!("../input/day04.txt");
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day05.txt");
|
const INPUT: &str = include_str!("../input/day05.txt");
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,3 @@ pub mod day02;
|
||||||
pub mod day03;
|
pub mod day03;
|
||||||
pub mod day04;
|
pub mod day04;
|
||||||
pub mod day05;
|
pub mod day05;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! err {
|
|
||||||
($($string:expr),+) => (Box::<dyn std::error::Error>::from(format!($($string),+)))
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
use aoc::Result;
|
||||||
|
|
||||||
use aoc2018::day01;
|
use aoc2018::day01;
|
||||||
use aoc2018::day02;
|
use aoc2018::day02;
|
||||||
use aoc2018::day03;
|
use aoc2018::day03;
|
||||||
use aoc2018::day04;
|
use aoc2018::day04;
|
||||||
use aoc2018::day05;
|
use aoc2018::day05;
|
||||||
|
|
||||||
use aoc2018::Result;
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let days: &[fn() -> Result<()>] = &[day01::run, day02::run, day03::run, day04::run, day05::run];
|
let days: &[fn() -> Result<()>] = &[day01::run, day02::run, day03::run, day04::run, day05::run];
|
||||||
|
|
||||||
|
|
|
@ -7,3 +7,5 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
aoc = { path = "../aoc" }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::Result;
|
use aoc::Result;
|
||||||
|
|
||||||
const INPUT: &str = include_str!("../input/day01.txt");
|
const INPUT: &str = include_str!("../input/day01.txt");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue