diff --git a/2021/.vscode/settings.json b/2021/.vscode/settings.json new file mode 100644 index 0000000..aa1c94e --- /dev/null +++ b/2021/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "deno.enable": true, + "deno.unstable": true +} diff --git a/2021/Cargo.toml b/2021/Cargo.toml new file mode 100644 index 0000000..536f3a5 --- /dev/null +++ b/2021/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ["./*/src/.."] diff --git a/2021/README.md b/2021/README.md new file mode 100644 index 0000000..a389464 --- /dev/null +++ b/2021/README.md @@ -0,0 +1,21 @@ +# Aoc 2021 + +Rust + Deno :heart: + +## Generate a new day with Rust + +```bash +cargo generate --git https://github.com/icyJoseph/advent-of-code.git template --name day-1 +``` + +## Run Rust binaries + +```bash +cargo run --bin day-1 +``` + +## Run Deno scripts + +```bash +deno run --allow-read --allow-write deno/day-1.ts +``` diff --git a/2021/day-1/Cargo.toml b/2021/day-1/Cargo.toml new file mode 100644 index 0000000..6d0af66 --- /dev/null +++ b/2021/day-1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +authors = ["Joseph Chamochumbi "] +edition = "2018" +name = "day-1" +version = "0.1.0" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +aoc = {git = "https://github.com/icyJoseph/advent-of-code.git"} diff --git a/2021/day-1/src/main.rs b/2021/day-1/src/main.rs new file mode 100644 index 0000000..824004a --- /dev/null +++ b/2021/day-1/src/main.rs @@ -0,0 +1,14 @@ +use aoc; + +fn solve(raw: String) -> () { + println!("{}", raw); +} + +fn main() { + let input = aoc::get_input(2021, 1); + + let raw_input = std::fs::read_to_string("./input/day-1.in").expect("Error reading input"); + + solve(input); + solve(raw_input); +} diff --git a/2021/deno/day-1.ts b/2021/deno/day-1.ts new file mode 100644 index 0000000..3d48850 --- /dev/null +++ b/2021/deno/day-1.ts @@ -0,0 +1,12 @@ +const input = await Deno.readTextFile("./input/day-1.in"); + +/** + * Part One + */ + +console.log("Part One:", input); + +/** + * Part Two + */ +console.log("Part Two:", input);