initial commit: templates, etc.
This commit is contained in:
commit
967419e50e
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
/in
|
||||
32
Cargo.lock
generated
Normal file
32
Cargo.lock
generated
Normal file
@ -0,0 +1,32 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
||||
|
||||
[[package]]
|
||||
name = "aoc2024"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "aoc2024"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.93"
|
||||
itertools = "0.13.0"
|
||||
23
src/days.rs
Normal file
23
src/days.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// pub mod d2;
|
||||
// pub mod d3;
|
||||
// pub mod d4;
|
||||
// pub mod d5;
|
||||
// pub mod d6;
|
||||
// pub mod d7;
|
||||
// pub mod d8;
|
||||
// pub mod d9;
|
||||
// pub mod d10;
|
||||
// pub mod d11;
|
||||
// pub mod d12;
|
||||
// pub mod d13;
|
||||
// pub mod d14;
|
||||
// pub mod d15;
|
||||
// pub mod d16;
|
||||
// pub mod d17;
|
||||
// pub mod d18;
|
||||
// pub mod d19;
|
||||
// pub mod d20;
|
||||
// pub mod d21;
|
||||
// pub mod d22;
|
||||
// pub mod d23;
|
||||
// pub mod d24;
|
||||
7
src/lib.rs
Normal file
7
src/lib.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#![feature(let_chains)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(iter_array_chunks)]
|
||||
|
||||
pub mod days;
|
||||
pub mod utils;
|
||||
pub mod prelude;
|
||||
9
src/prelude.rs
Normal file
9
src/prelude.rs
Normal file
@ -0,0 +1,9 @@
|
||||
pub use crate::utils::*;
|
||||
pub use anyhow::Error;
|
||||
pub use itertools::Itertools;
|
||||
pub use std::{
|
||||
collections::{ HashMap as M, HashSet as S, VecDeque as D },
|
||||
cmp::Ordering as Or,
|
||||
};
|
||||
|
||||
pub type SS = &'static str;
|
||||
54
src/template.rs
Normal file
54
src/template.rs
Normal file
@ -0,0 +1,54 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub type I = Vec<String>;
|
||||
pub type O = i64;
|
||||
|
||||
fn _parse (data: &str) -> I {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn _solve (data: &I) -> O {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn _silver (data: &I) -> O {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn _gold (data: &I) -> O {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
fn read () -> I {
|
||||
let data = inc!(_);
|
||||
_parse(data)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sample () {
|
||||
let data = "";
|
||||
let data = _parse(data);
|
||||
|
||||
assert_eq!(1, 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn silver () {
|
||||
let data = read();
|
||||
let ans = _silver(&data);
|
||||
|
||||
assert_eq!(ans, 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gold () {
|
||||
let data = read();
|
||||
let ans = _gold(&data);
|
||||
|
||||
assert_eq!(ans, 1)
|
||||
}
|
||||
}
|
||||
24
src/utils.rs
Normal file
24
src/utils.rs
Normal file
@ -0,0 +1,24 @@
|
||||
pub macro inc {
|
||||
($d: literal) => {
|
||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/in/", $d, ".txt"))
|
||||
}
|
||||
}
|
||||
|
||||
pub macro s {
|
||||
($s: literal) => {
|
||||
format!("{}", $s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub macro p {
|
||||
($s: expr) => {
|
||||
$s.parse().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
pub macro n {
|
||||
($s: expr) => {
|
||||
$s.next().unwrap()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user