Compare commits

..

No commits in common. "0df2dd8dd801d01e01009abd57a583457a928f00" and "175318322e77b54dad6aa1e28080286e97bcf8c9" have entirely different histories.

10 changed files with 18 additions and 1152 deletions

9
Cargo.lock generated
View file

@ -115,15 +115,6 @@ dependencies = [
"criterion 0.4.0", "criterion 0.4.0",
] ]
[[package]]
name = "aoc2023"
version = "0.1.0"
dependencies = [
"anyhow",
"aoc",
"criterion 0.4.0",
]
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"

View file

@ -1,9 +1,7 @@
[workspace] [workspace]
members = ["aoc20*", "aoc20*/aoc20*_bench"] members = ["aoc20*", "aoc20*/aoc20*_bench"]
default-members = ["aoc2023"] default-members = ["aoc2022"]
resolver = "2"
[profile.release] [profile.release]
debug = true debug = true

View file

@ -1,21 +0,0 @@
[package]
name = "aoc2023"
version = "0.1.0"
authors = ["Antoine Martin <antoine@alarsyo.net>"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
aoc = { path = "../aoc" }
anyhow = "1.0"
[dev-dependencies]
criterion = { version = "0.4", default-features = false, features = [ "rayon" ] }
[lib]
path = "src/lib.rs"
[[bin]]
name = "aoc2023"
path = "src/main.rs"

File diff suppressed because it is too large Load diff

View file

@ -1,4 +0,0 @@
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

View file

@ -1,50 +0,0 @@
use std::fmt::Write;
use anyhow::Result;
const INPUT: &str = include_str!("../input/day01.txt");
pub fn run() -> Result<String> {
let mut res = String::with_capacity(128);
writeln!(res, "part 1: {}", part1(INPUT)?)?;
writeln!(res, "part 2: {}", part2(INPUT)?)?;
Ok(res)
}
fn part1(input: &str) -> Result<u64> {
let digit_list = input
.lines()
.map(|s| s.chars().filter(char::is_ascii_digit).collect::<String>());
Ok(digit_list
.map(|digits| {
let first = digits.chars().next().unwrap().to_digit(10).unwrap() as u64;
let last = digits.chars().last().unwrap().to_digit(10).unwrap() as u64;
first * 10 + last
})
.sum())
}
fn part2(input: &str) -> Result<u64> {
todo!()
}
#[cfg(test)]
mod tests {
use super::*;
const PROVIDED: &str = include_str!("../input/day01_provided.txt");
#[test]
fn part1_provided() {
assert_eq!(part1(PROVIDED).unwrap(), 142);
}
#[test]
fn part1_real() {
assert_eq!(part1(INPUT).unwrap(), 54697);
}
}

View file

@ -1 +0,0 @@
pub mod day01;

View file

@ -1,11 +0,0 @@
use anyhow::Result;
use aoc::DayFunc;
use aoc2023::day01;
fn main() -> Result<()> {
let days: &[DayFunc] = &[day01::run];
aoc::run(days)
}

View file

@ -1,15 +1,12 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1694529238, "lastModified": 1667395993,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -19,15 +16,12 @@
} }
}, },
"flake-utils_2": { "flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": { "locked": {
"lastModified": 1681202837, "lastModified": 1659877975,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401", "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -38,27 +32,27 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1701389149, "lastModified": 1669834992,
"narHash": "sha256-rU1suTIEd5DGCaAXKW6yHoCfR1mnYjOXQFOaH7M23js=", "narHash": "sha256-YnhZGHgb4C3Q7DSGisO/stc50jFb9F/MzHeKS4giotg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5de0b32be6e85dc1a9404c75131316e4ffbc634c", "rev": "596a8e828c5dfa504f91918d0fa4152db3ab5502",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-23.11", "ref": "nixos-22.11",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1681358109, "lastModified": 1665296151,
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -81,11 +75,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1701483183, "lastModified": 1670207212,
"narHash": "sha256-MDH3oUajqTaYClCiq1QK7jWVMtMFDJWxVBCFAnkt6J4=", "narHash": "sha256-uuKbbv0L+QoXiqO7METP9BihY0F7hJqGdKn7xDVfyFw=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "47fe4578cb64a365f400e682a70e054657c42fa5", "rev": "18823e511bc85ed27bfabe33cccecb389f9aa92d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -93,36 +87,6 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -1,6 +1,6 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };