Initial commit

This commit is contained in:
JonOfUs 2024-11-19 22:13:39 +01:00
commit 08385f672a
7 changed files with 397 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

243
Cargo.lock generated Normal file
View file

@ -0,0 +1,243 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "advent-of-code-2024"
version = "0.1.0"
dependencies = [
"automod",
"num",
"rayon",
"regex",
"scan_fmt",
]
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "autocfg"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "automod"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "either"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "num"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-bigint"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
dependencies = [
"num-integer",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
dependencies = [
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
"num-bigint",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "proc-macro2"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rayon"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "scan_fmt"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b53b0a5db882a8e2fdaae0a43f7b39e7e9082389e978398bdf223a55b581248"
dependencies = [
"regex",
]
[[package]]
name = "syn"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"

13
Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "advent-of-code-2024"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
automod = "1.0.13"
num = "0.4.1"
rayon = "1.8.0"
regex = "1.10.2"
scan_fmt = "0.2.6"

0
res/.gitkeep Normal file
View file

1
src/days.rs Normal file
View file

@ -0,0 +1 @@
automod::dir!(pub "src/days");

10
src/days/d01.rs Normal file
View file

@ -0,0 +1,10 @@
use std::collections::HashMap;
use std::fs;
pub fn solve() {
let path = "res/01/input";
println!("Result 1: {}", 42);
println!("Result 2: {}", 42);
}

129
src/main.rs Normal file
View file

@ -0,0 +1,129 @@
pub mod days;
#[macro_use]
extern crate scan_fmt;
use std::time::Instant;
fn main() {
days::d01::solve()
//_all_days()
}
#[allow(unreachable_code, unused)]
fn _all_days() {
let start = Instant::now();
let mut time = start.clone();
println!("\nDay 1");
days::d01::solve();
time = _print_elapsed(time);
/*
println!("\nDay 2");
days::d02::solve();
time = _print_elapsed(time);
println!("\nDay 3");
days::d03::solve();
time = _print_elapsed(time);
println!("\nDay 4");
days::d04::solve();
time = _print_elapsed(time);
println!("\nDay 5");
days::d05::solve();
time = _print_elapsed(time);
println!("\nDay 6");
days::d06::solve();
time = _print_elapsed(time);
println!("\nDay 7");
days::d07::solve();
time = _print_elapsed(time);
println!("\nDay 8");
days::d08::solve();
time = _print_elapsed(time);
println!("\nDay 9");
days::d09::solve();
time = _print_elapsed(time);
println!("\nDay 10");
days::d10::solve();
time = _print_elapsed(time);
println!("\nDay 11");
days::d11::solve();
time = _print_elapsed(time);
println!("\nDay 12");
days::d12::solve();
time = _print_elapsed(time);
println!("\nDay 13");
days::d13::solve();
time = _print_elapsed(time);
println!("\nDay 14");
days::d14::solve();
time = _print_elapsed(time);
println!("\nDay 15");
days::d15::solve();
time = _print_elapsed(time);
println!("\nDay 16");
days::d16::solve();
time = _print_elapsed(time);
println!("\nDay 17");
days::d17::solve();
time = _print_elapsed(time);
println!("\nDay 18");
days::d18::solve();
time = _print_elapsed(time);
println!("\nDay 19");
days::d19::solve();
time = _print_elapsed(time);
println!("\nDay 20");
days::d20::solve();
time = _print_elapsed(time);
println!("\nDay 21");
days::d21::solve();
time = _print_elapsed(time);
println!("\nDay 22");
days::d22::solve();
time = _print_elapsed(time);
println!("\nDay 23");
days::d23::solve();
time = _print_elapsed(time);
println!("\nDay 24");
days::d24::solve();
time = _print_elapsed(time);
println!("\nDay 25");
days::d25::solve();
_print_elapsed(time);*/
println!("\nTotal elapsed: {}ms", start.elapsed().as_millis())
}
fn _print_elapsed(time: Instant) -> Instant {
println!(
" Elapsed: {}.{}ms",
time.elapsed().as_millis(),
time.elapsed().as_micros() % 1000
);
Instant::now()
}