Compare commits

..

No commits in common. "a5fa4b628e8ccfeec2b99df04f0e2ea9d50e663c" and "294c0a8e6231ca4e8a1c1b776673b93a0d12422c" have entirely different histories.

77 changed files with 171 additions and 4792 deletions

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
set -e
if [[ ! -d "/home/spectre/code/aocrust" ]]; then
echo "Cannot find source directory; Did you move it?"
echo "(Looking for "/home/spectre/code/aocrust")"
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
exit 1
fi
# rebuild the cache forcefully
_nix_direnv_force_reload=1 direnv exec "/home/spectre/code/aocrust" true
# Update the mtime for .envrc.
# This will cause direnv to reload again - but without re-building.
touch "/home/spectre/code/aocrust/.envrc"
# Also update the timestamp of whatever profile_rc we have.
# This makes sure that we know we are up to date.
touch -r "/home/spectre/code/aocrust/.envrc" "/home/spectre/code/aocrust/.direnv"/*.rc

View file

@ -1 +0,0 @@
/nix/store/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source

View file

@ -1 +0,0 @@
/nix/store/21j7n6lxhfshy95gi0zr4vwswgy294jm-source

View file

@ -1 +0,0 @@
/nix/store/63wl439w735818rb3sl7ks63raqzqxx2-source

View file

@ -1 +0,0 @@
/nix/store/ab78nf3ad8ly49zfyd3igw3f2n5q7fz4-source

View file

@ -1 +0,0 @@
/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source

View file

@ -1 +0,0 @@
/nix/store/3zv4qkyn3yqzksv0kbrbqy73yfpqi152-nix-shell-env

1
.envrc
View file

@ -1 +0,0 @@
use flake

8
.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

15
.idea/AdventOfCode.iml generated Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/aoc2023/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/shared/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/AdventOfCode.iml" filepath="$PROJECT_DIR$/.idea/AdventOfCode.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

1604
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,10 +6,8 @@ edition = "2021"
# 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
[workspace] [workspace]
members = ["shared", "aoc2023", "aoc2024"] members = ["shared", "aoc2023"]
[dependencies] [dependencies]
shared = { path = "shared" } shared = { path = "shared" }
aoc2023 = { path = "aoc2023" } aoc2023 = { path = "aoc2023" }
aoc2024 = { path = "aoc2024" }
reqwest = { version = "0.12.9", features = ["cookies", "blocking"] }

View file

@ -1,4 +1,4 @@
use shared::{Answer, Solution}; use shared::{Answer, load_test, Solution};
use regex::{Regex}; use regex::{Regex};
pub struct Day01; pub struct Day01;

View file

@ -1,118 +1,58 @@
use shared::{Solution, Answer}; use shared::Solution;
use crate::day01::Day01;
use crate::day02::Day02;
use crate::day03::Day03;
use crate::day04::Day04;
use crate::day05::Day05;
use crate::day06::Day06;
use crate::day07::Day07;
use crate::day08::Day08;
use crate::day09::Day09;
use crate::day10::Day10;
use crate::day11::Day11;
use crate::day12::Day12;
use crate::day13::Day13;
use crate::day14::Day14;
use crate::day15::Day15;
use crate::day16::Day16;
use crate::day17::Day17;
use crate::day18::Day18;
use crate::day19::Day19;
use crate::day20::Day20;
use crate::day21::Day21;
use crate::day22::Day22;
use crate::day23::Day23;
use crate::day24::Day24;
use crate::day25::Day25;
pub use crate::day01::Day01; pub mod day01;
pub use crate::day02::Day02; pub mod day02;
pub use crate::day03::Day03; pub mod day03;
pub use crate::day04::Day04; pub mod day04;
pub use crate::day05::Day05; pub mod day05;
pub use crate::day06::Day06; pub mod day06;
pub use crate::day07::Day07; pub mod day07;
pub use crate::day08::Day08; pub mod day08;
pub use crate::day09::Day09; pub mod day09;
pub use crate::day10::Day10; pub mod day10;
pub use crate::day11::Day11;
pub use crate::day12::Day12;
pub use crate::day13::Day13;
pub use crate::day14::Day14;
pub use crate::day15::Day15;
pub use crate::day16::Day16;
pub use crate::day17::Day17;
pub use crate::day18::Day18;
pub use crate::day19::Day19;
pub use crate::day20::Day20;
pub use crate::day21::Day21;
pub use crate::day22::Day22;
pub use crate::day23::Day23;
pub use crate::day24::Day24;
pub use crate::day25::Day25;
pub fn solution(input: &str, day: usize, part: usize) -> Option<Answer> { pub mod day11;
match part {
1 => match day {
1 => Some(Day01.part_1(input)),
2 => Some(Day02.part_1(input)),
3 => Some(Day03.part_1(input)),
4 => Some(Day04.part_1(input)),
5 => Some(Day05.part_1(input)),
6 => Some(Day06.part_1(input)),
7 => Some(Day07.part_1(input)),
8 => Some(Day08.part_1(input)),
9 => Some(Day09.part_1(input)),
10 => Some(Day10.part_1(input)),
11 => Some(Day11.part_1(input)),
12 => Some(Day12.part_1(input)),
13 => Some(Day13.part_1(input)),
14 => Some(Day14.part_1(input)),
15 => Some(Day15.part_1(input)),
16 => Some(Day16.part_1(input)),
17 => Some(Day17.part_1(input)),
18 => Some(Day18.part_1(input)),
19 => Some(Day19.part_1(input)),
20 => Some(Day20.part_1(input)),
21 => Some(Day21.part_1(input)),
22 => Some(Day22.part_1(input)),
23 => Some(Day23.part_1(input)),
24 => Some(Day24.part_1(input)),
25 => Some(Day25.part_1(input)),
_ => None
},
2 => match day {
1 => Some(Day01.part_2(input)),
2 => Some(Day02.part_2(input)),
3 => Some(Day03.part_2(input)),
4 => Some(Day04.part_2(input)),
5 => Some(Day05.part_2(input)),
6 => Some(Day06.part_2(input)),
7 => Some(Day07.part_2(input)),
8 => Some(Day08.part_2(input)),
9 => Some(Day09.part_2(input)),
10 => Some(Day10.part_2(input)),
11 => Some(Day11.part_2(input)),
12 => Some(Day12.part_2(input)),
13 => Some(Day13.part_2(input)),
14 => Some(Day14.part_2(input)),
15 => Some(Day15.part_2(input)),
16 => Some(Day16.part_2(input)),
17 => Some(Day17.part_2(input)),
18 => Some(Day18.part_2(input)),
19 => Some(Day19.part_2(input)),
20 => Some(Day20.part_2(input)),
21 => Some(Day21.part_2(input)),
22 => Some(Day22.part_2(input)),
23 => Some(Day23.part_2(input)),
24 => Some(Day24.part_2(input)),
25 => Some(Day25.part_2(input)),
_ => None
},
_ => None
}
}
mod day01; pub mod day12;
mod day02;
mod day03; pub mod day13;
mod day04; pub mod day14;
mod day05; pub mod day15;
mod day06; pub mod day16;
mod day07; pub mod day17;
mod day08; pub mod day18;
mod day09; pub mod day19;
mod day10; pub mod day20;
mod day11; pub mod day21;
mod day12; pub mod day22;
mod day13; pub mod day23;
mod day14; pub mod day24;
mod day15; pub mod day25;
mod day16;
mod day17;
mod day18;
mod day19;
mod day20;
mod day21;
mod day22;
mod day23;
mod day24;
mod day25;
#[test] #[test]
fn examples() { fn examples() {

View file

@ -1,10 +0,0 @@
[package]
name = "aoc2024"
version = "0.1.0"
edition = "2021"
[dependencies]
shared = { path = "../shared" }
regex = "1.10.2"
substring = "1.4.5"
itertools = "0.12.0"

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day01;
impl Solution for Day01 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day02;
impl Solution for Day02 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day03;
impl Solution for Day03 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day04;
impl Solution for Day04 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day05;
impl Solution for Day05 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day06;
impl Solution for Day06 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day07;
impl Solution for Day07 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day08;
impl Solution for Day08 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day09;
impl Solution for Day09 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day10;
impl Solution for Day10 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day11;
impl Solution for Day11 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day12;
impl Solution for Day12 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day13;
impl Solution for Day13 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day14;
impl Solution for Day14 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day15;
impl Solution for Day15 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day16;
impl Solution for Day16 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day17;
impl Solution for Day17 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day18;
impl Solution for Day18 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day19;
impl Solution for Day19 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day20;
impl Solution for Day20 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day21;
impl Solution for Day21 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day22;
impl Solution for Day22 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day23;
impl Solution for Day23 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day24;
impl Solution for Day24 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day25;
impl Solution for Day25 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,120 +0,0 @@
use shared::{Solution, Answer};
pub use crate::day01::Day01;
pub use crate::day02::Day02;
pub use crate::day03::Day03;
pub use crate::day04::Day04;
pub use crate::day05::Day05;
pub use crate::day06::Day06;
pub use crate::day07::Day07;
pub use crate::day08::Day08;
pub use crate::day09::Day09;
pub use crate::day10::Day10;
pub use crate::day11::Day11;
pub use crate::day12::Day12;
pub use crate::day13::Day13;
pub use crate::day14::Day14;
pub use crate::day15::Day15;
pub use crate::day16::Day16;
pub use crate::day17::Day17;
pub use crate::day18::Day18;
pub use crate::day19::Day19;
pub use crate::day20::Day20;
pub use crate::day21::Day21;
pub use crate::day22::Day22;
pub use crate::day23::Day23;
pub use crate::day24::Day24;
pub use crate::day25::Day25;
pub fn solution(input: &str, day: usize, part: usize) -> Option<Answer> {
match part {
1 => match day {
1 => Some(Day01.part_1(input)),
2 => Some(Day02.part_1(input)),
3 => Some(Day03.part_1(input)),
4 => Some(Day04.part_1(input)),
5 => Some(Day05.part_1(input)),
6 => Some(Day06.part_1(input)),
7 => Some(Day07.part_1(input)),
8 => Some(Day08.part_1(input)),
9 => Some(Day09.part_1(input)),
10 => Some(Day10.part_1(input)),
11 => Some(Day11.part_1(input)),
12 => Some(Day12.part_1(input)),
13 => Some(Day13.part_1(input)),
14 => Some(Day14.part_1(input)),
15 => Some(Day15.part_1(input)),
16 => Some(Day16.part_1(input)),
17 => Some(Day17.part_1(input)),
18 => Some(Day18.part_1(input)),
19 => Some(Day19.part_1(input)),
20 => Some(Day20.part_1(input)),
21 => Some(Day21.part_1(input)),
22 => Some(Day22.part_1(input)),
23 => Some(Day23.part_1(input)),
24 => Some(Day24.part_1(input)),
25 => Some(Day25.part_1(input)),
_ => None
},
2 => match day {
1 => Some(Day01.part_2(input)),
2 => Some(Day02.part_2(input)),
3 => Some(Day03.part_2(input)),
4 => Some(Day04.part_2(input)),
5 => Some(Day05.part_2(input)),
6 => Some(Day06.part_2(input)),
7 => Some(Day07.part_2(input)),
8 => Some(Day08.part_2(input)),
9 => Some(Day09.part_2(input)),
10 => Some(Day10.part_2(input)),
11 => Some(Day11.part_2(input)),
12 => Some(Day12.part_2(input)),
13 => Some(Day13.part_2(input)),
14 => Some(Day14.part_2(input)),
15 => Some(Day15.part_2(input)),
16 => Some(Day16.part_2(input)),
17 => Some(Day17.part_2(input)),
18 => Some(Day18.part_2(input)),
19 => Some(Day19.part_2(input)),
20 => Some(Day20.part_2(input)),
21 => Some(Day21.part_2(input)),
22 => Some(Day22.part_2(input)),
23 => Some(Day23.part_2(input)),
24 => Some(Day24.part_2(input)),
25 => Some(Day25.part_2(input)),
_ => None
},
_ => None
}
}
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
mod day06;
mod day07;
mod day08;
mod day09;
mod day10;
mod day11;
mod day12;
mod day13;
mod day14;
mod day15;
mod day16;
mod day17;
mod day18;
mod day19;
mod day20;
mod day21;
mod day22;
mod day23;
mod day24;
mod day25;
#[test]
fn examples() {
todo!()
}

26
flake.lock generated
View file

@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1731533236, "lastModified": 1681202837,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,39 +20,37 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1733015953, "lastModified": 1703134684,
"narHash": "sha256-t4BBVpwG9B4hLgc6GUBuj3cjU7lP/PJfpTHuSqE+crk=", "narHash": "sha256-SQmng1EnBFLzS7WSRyPM9HgmZP2kLJcPAz+Ug/nug6o=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ac35b104800bff9028425fec3b6e8a41de2bbfff", "rev": "d6863cbcbbb80e71cecfc03356db1cda38919523",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "id": "nixpkgs",
"ref": "nixos-unstable", "type": "indirect"
"repo": "nixpkgs",
"type": "github"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1733106880, "lastModified": 1689302058,
"narHash": "sha256-aJmAIjZfWfPSWSExwrYBLRgXVvgF5LP1vaeUGOOIQ98=", "narHash": "sha256-yD74lcHTrw4niXcE9goJLbzsgyce48rQQoy5jK5ZK40=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "e66c0d43abf5bdefb664c3583ca8994983c332ae", "rev": "7b8dbbf4c67ed05a9bf3d9e658c12d4108bc24c8",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,9 +1,7 @@
{ {
description = "Dev Shell for AdventOfCode by lilith"; description = "A Nix-flake-based Rust development environment";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -11,35 +9,42 @@
}; };
outputs = { outputs = {
self,
nixpkgs, nixpkgs,
rust-overlay, rust-overlay,
flake-utils, }: let
... overlays = [
}: rust-overlay.overlays.default
flake-utils.lib.eachDefaultSystem ( (final: prev: {
system: let rustToolchain = let
overlays = [(import rust-overlay)]; rust = prev.rust-bin;
pkgs = import nixpkgs { in
inherit system overlays; if builtins.pathExists ./rust-toolchain.toml
}; then rust.fromRustupToolchainFile ./rust-toolchain.toml
in { else if builtins.pathExists ./rust-toolchain
devShells.default = with pkgs; then rust.fromRustupToolchainFile ./rust-toolchain
mkShell { else rust.stable.latest.default;
buildInputs = [ })
openssl ];
pkg-config supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
cargo-deny forEachSupportedSystem = f:
cargo-edit nixpkgs.lib.genAttrs supportedSystems (system:
cargo-watch f {
rust-analyzer pkgs = import nixpkgs {inherit overlays system;};
( });
rust-bin.selectLatestNightlyWith (toolchain: in {
toolchain.default.override { devShells = forEachSupportedSystem ({pkgs}: {
extensions = ["rust-src"]; default = pkgs.mkShell {
}) packages = with pkgs; [
) rustToolchain
]; openssl
}; pkg-config
} cargo-deny
); cargo-edit
cargo-watch
rust-analyzer
];
};
});
};
} }

View file

@ -1,11 +1,11 @@
use std::{fs, io}; use std::{fs, io};
pub fn load_actual(year: usize, day: usize) -> io::Result<String> { pub fn load_actual(year: u64, day: u64) -> io::Result<String> {
let path = format!("./data/{year}/day{:02}", day); let path = format!("./data/{year}/day{:02}", day);
fs::read_to_string(path) fs::read_to_string(path)
} }
pub fn load_test(year: usize, day: usize) -> io::Result<String> { pub fn load_test(year: u64, day: u64) -> io::Result<String> {
let path = format!("./examples/{year}/day{:02}", day); let path = format!("./examples/{year}/day{:02}", day);
fs::read_to_string(path) fs::read_to_string(path)
} }

View file

@ -1,6 +1,9 @@
mod answer; mod answer;
mod input_data;
mod solution; mod solution;
pub use answer::Answer; pub use answer::Answer;
pub use solution::Solution; pub use solution::Solution;
pub use input_data::{load_test, load_actual};

View file

@ -1,52 +1,20 @@
mod solution; use shared::Solution;
use solution::solution;
mod input_data; use shared::load_actual;
use input_data::load_actual;
use reqwest::blocking::Client; use std::time::Instant;
use reqwest::header::COOKIE;
use std::{time::Instant, env};
fn main() { fn main() {
let year = 2024; let now = Instant::now();
let day = 2;
fetch_data(year, day).unwrap(); let Ok(data) = load_actual(2023, 12)
let Ok(data) = load_actual(year, day)
else { panic!("No Input Data"); }; else { panic!("No Input Data"); };
let now = Instant::now(); let result = aoc2023::day12::Day12.part_2(&data);
let part1 = solution(&data, year, day, 1).unwrap(); let elapsed = now.elapsed();
let elapsed1 = now.elapsed(); println!("{}", result);
let now = Instant::now();
let part2 = solution(&data, year, day, 2).unwrap();
let elapsed2 = now.elapsed();
println!("Part 1 result is {}, took {}ms", part1, elapsed1.as_millis());
println!("Part 2 result is {}, took {}ms", part2, elapsed2.as_millis());
} println!("{:?}", elapsed);
fn fetch_data(year: usize, day: usize) -> Result<(), Box<dyn std::error::Error>> {
let url = format!("https://adventofcode.com/{year}/day/{day}/input");
let session_cookie = env::var("ADVENT_TOKEN")?;
let client = Client::new();
let response = client
.get(url)
.header(COOKIE, session_cookie)
.send()?;
let body = response.text();
println!("Response: {:?}", body);
Ok(())
} }

View file

@ -1,10 +0,0 @@
use shared::Answer;
pub fn solution(input: &str, year: usize, day: usize, part: usize) -> Option<Answer> {
match year {
2023 => aoc2024::solution(input, day, part),
2024 => aoc2024::solution(input, day, part),
_ => None,
}
}

View file

@ -1,7 +0,0 @@
[package]
name = "aoc202X"
version = "0.1.0"
edition = "2021"
[dependencies]
shared = { path = "../shared" }

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day01;
impl Solution for Day01 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day02;
impl Solution for Day02 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day03;
impl Solution for Day03 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day04;
impl Solution for Day04 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day05;
impl Solution for Day05 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day06;
impl Solution for Day06 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day07;
impl Solution for Day07 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day08;
impl Solution for Day08 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day09;
impl Solution for Day09 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day10;
impl Solution for Day10 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day11;
impl Solution for Day11 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day12;
impl Solution for Day12 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day13;
impl Solution for Day13 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day14;
impl Solution for Day14 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day15;
impl Solution for Day15 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day16;
impl Solution for Day16 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day17;
impl Solution for Day17 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day18;
impl Solution for Day18 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day19;
impl Solution for Day19 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day20;
impl Solution for Day20 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day21;
impl Solution for Day21 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day22;
impl Solution for Day22 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day23;
impl Solution for Day23 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day24;
impl Solution for Day24 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,13 +0,0 @@
use shared::{Solution, Answer};
pub struct Day25;
impl Solution for Day25 {
fn part_1(&self, input: &str) -> Answer {
Answer::Unimplemented
}
fn part_2(&self, input: &str) -> Answer {
Answer::Unimplemented
}
}

View file

@ -1,120 +0,0 @@
use shared::{Solution, Answer};
pub use crate::day01::Day01;
pub use crate::day02::Day02;
pub use crate::day03::Day03;
pub use crate::day04::Day04;
pub use crate::day05::Day05;
pub use crate::day06::Day06;
pub use crate::day07::Day07;
pub use crate::day08::Day08;
pub use crate::day09::Day09;
pub use crate::day10::Day10;
pub use crate::day11::Day11;
pub use crate::day12::Day12;
pub use crate::day13::Day13;
pub use crate::day14::Day14;
pub use crate::day15::Day15;
pub use crate::day16::Day16;
pub use crate::day17::Day17;
pub use crate::day18::Day18;
pub use crate::day19::Day19;
pub use crate::day20::Day20;
pub use crate::day21::Day21;
pub use crate::day22::Day22;
pub use crate::day23::Day23;
pub use crate::day24::Day24;
pub use crate::day25::Day25;
pub fn solution(input: &str, day: usize, part: usize) -> Option<Answer> {
match part {
1 => match day {
1 => Some(Day01.part_1(input)),
2 => Some(Day02.part_1(input)),
3 => Some(Day03.part_1(input)),
4 => Some(Day04.part_1(input)),
5 => Some(Day05.part_1(input)),
6 => Some(Day06.part_1(input)),
7 => Some(Day07.part_1(input)),
8 => Some(Day08.part_1(input)),
9 => Some(Day09.part_1(input)),
10 => Some(Day10.part_1(input)),
11 => Some(Day11.part_1(input)),
12 => Some(Day12.part_1(input)),
13 => Some(Day13.part_1(input)),
14 => Some(Day14.part_1(input)),
15 => Some(Day15.part_1(input)),
16 => Some(Day16.part_1(input)),
17 => Some(Day17.part_1(input)),
18 => Some(Day18.part_1(input)),
19 => Some(Day19.part_1(input)),
20 => Some(Day20.part_1(input)),
21 => Some(Day21.part_1(input)),
22 => Some(Day22.part_1(input)),
23 => Some(Day23.part_1(input)),
24 => Some(Day24.part_1(input)),
25 => Some(Day25.part_1(input)),
_ => None
},
2 => match day {
1 => Some(Day01.part_2(input)),
2 => Some(Day02.part_2(input)),
3 => Some(Day03.part_2(input)),
4 => Some(Day04.part_2(input)),
5 => Some(Day05.part_2(input)),
6 => Some(Day06.part_2(input)),
7 => Some(Day07.part_2(input)),
8 => Some(Day08.part_2(input)),
9 => Some(Day09.part_2(input)),
10 => Some(Day10.part_2(input)),
11 => Some(Day11.part_2(input)),
12 => Some(Day12.part_2(input)),
13 => Some(Day13.part_2(input)),
14 => Some(Day14.part_2(input)),
15 => Some(Day15.part_2(input)),
16 => Some(Day16.part_2(input)),
17 => Some(Day17.part_2(input)),
18 => Some(Day18.part_2(input)),
19 => Some(Day19.part_2(input)),
20 => Some(Day20.part_2(input)),
21 => Some(Day21.part_2(input)),
22 => Some(Day22.part_2(input)),
23 => Some(Day23.part_2(input)),
24 => Some(Day24.part_2(input)),
25 => Some(Day25.part_2(input)),
_ => None
},
_ => None
}
}
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
mod day06;
mod day07;
mod day08;
mod day09;
mod day10;
mod day11;
mod day12;
mod day13;
mod day14;
mod day15;
mod day16;
mod day17;
mod day18;
mod day19;
mod day20;
mod day21;
mod day22;
mod day23;
mod day24;
mod day25;
#[test]
fn examples() {
todo!()
}