diff --git a/.gitignore b/.gitignore index 377bd25..a67eab8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ node_modules *.txt .env* + + +# Added by cargo +/target diff --git a/2022/01/rust/main.rs b/2022/01/rust/main.rs new file mode 100644 index 0000000..639edd1 --- /dev/null +++ b/2022/01/rust/main.rs @@ -0,0 +1,10 @@ +fn main() { + // Part A + let result: u32 = include_str!("../input.txt") + .trim() + .split("\n\n") + .map(|x| x.lines().map(|x| x.parse::().unwrap()).sum()) + .max() + .unwrap(); + println!("A: {}", result); +} diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..325f0b8 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "advent-of-code" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..08fdd37 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "advent-of-code" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + +[[bin]] +name = "2022-01" +path = "./2022/01/rust/main.rs"