1
0
mirror of https://gitlab.com/MisterBiggs/aoc2021.git synced 2025-06-15 22:46:51 +00:00

refactor organization of repo

This commit is contained in:
Anson 2022-10-11 21:15:55 -06:00
parent 83a6196b20
commit 305ec1f29d
23 changed files with 45 additions and 173 deletions

6
.gitignore vendored
View File

@ -11,4 +11,8 @@ Cargo.lock
**/*.rs.bk **/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information # MSVC Windows builds of rustc generate these, which store debugging information
*.pdb *.pdb
# Added by cargo
/target

View File

@ -1,8 +1,9 @@
[package] [package]
name = "rust" name = "aoc2021"
version = "0.1.0" version = "0.1.0"
edition = "2021" 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
[dependencies] [dependencies]
itertools = "0.10.3"

View File

@ -1,9 +0,0 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/rust/.devcontainer/base.Dockerfile
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT}
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

View File

@ -1,46 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/rust
{
"name": "Rust",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
// Use bullseye when on local on arm64/Apple Silicon.
"VARIANT": "buster"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"matklad.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

7
day1/rust/Cargo.lock generated
View File

@ -1,7 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust"
version = "0.1.0"

View File

@ -1,8 +0,0 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -1,9 +0,0 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/rust/.devcontainer/base.Dockerfile
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT}
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

View File

@ -1,46 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/rust
{
"name": "Rust",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
// Use bullseye when on local on arm64/Apple Silicon.
"VARIANT": "buster"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"matklad.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

View File

@ -1,8 +0,0 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -1,8 +0,0 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -1,9 +0,0 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
itertools = "0.10"

View File

@ -1,2 +0,0 @@
[1204/174854.538:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
[1217/131743.085:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)

View File

@ -1,7 +1,8 @@
use std::fs; use std::fs;
fn main() { pub fn run() {
let input = fs::read_to_string("../input.txt").expect("Could not read file"); println!("Day 1:");
let input = fs::read_to_string("./inputs/day1.txt").expect("Could not read file");
let lines: Vec<i32> = input.lines().map(|s| s.parse().unwrap()).collect(); let lines: Vec<i32> = input.lines().map(|s| s.parse().unwrap()).collect();
@ -20,7 +21,7 @@ fn part1(lines: &Vec<i32>) {
previous = current; previous = current;
} }
println!("Increases: {}", increases); println!("\tPart 1: {}", increases);
} }
fn part2(lines: &Vec<i32>) { fn part2(lines: &Vec<i32>) {
@ -36,5 +37,5 @@ fn part2(lines: &Vec<i32>) {
previous = current; previous = current;
} }
println!("Increases: {}", increases); println!("\tPart 2: {}", increases);
} }

View File

@ -1,7 +1,8 @@
use std::fs; use std::fs;
fn main() { pub fn run() {
let input = fs::read_to_string("../input.txt").expect("Could not read file"); println!("Day 2:");
let input = fs::read_to_string("./inputs/day2.txt").expect("Could not read file");
let commands: Vec<(&str, i32)> = input let commands: Vec<(&str, i32)> = input
.lines() .lines()
@ -33,7 +34,7 @@ fn part1(commands: &Vec<(&str, i32)>) {
position += change.0; position += change.0;
depth += change.1; depth += change.1;
} }
println!("Part 1: {}", position * depth); println!("\tPart 1: {}", position * depth);
} }
fn part2(commands: &Vec<(&str, i32)>) { fn part2(commands: &Vec<(&str, i32)>) {
@ -53,5 +54,5 @@ fn part2(commands: &Vec<(&str, i32)>) {
position += change.0; position += change.0;
depth += aim * change.0; depth += aim * change.0;
} }
println!("Part 2: {}", position * depth); println!("\tPart 2: {}", position * depth);
} }

View File

@ -1,7 +1,8 @@
use std::fs; use std::fs;
fn main() { pub fn run() {
let input = fs::read_to_string("../input.txt").expect("Could not read file"); println!("Day 3:");
let input = fs::read_to_string("./inputs/day3.txt").expect("Could not read file");
let report: Vec<&str> = input.lines().collect(); let report: Vec<&str> = input.lines().collect();
let bit_count = report[0].len(); let bit_count = report[0].len();
@ -28,7 +29,7 @@ fn main() {
epsilon += 1; epsilon += 1;
} }
} }
println!("Part 1: {}", gamma * epsilon); println!("\tPart 1: {}", gamma * epsilon);
} }
{ {
@ -79,6 +80,6 @@ fn main() {
i32::from_str_radix(diagnostic[0], 2).unwrap() i32::from_str_radix(diagnostic[0], 2).unwrap()
}; };
println!("Part 2: {}", generator * scrubber); println!("\tPart 2: {}", generator * scrubber);
} }
} }

View File

@ -1,16 +1,17 @@
use std::fs; use std::fs;
fn main() { pub fn run() {
let input = fs::read_to_string("../input.txt").expect("Could not read file"); println!("Day 4:");
let input = fs::read_to_string("./inputs/day4.txt").expect("Could not read file");
let numbers: Vec<&str> = input.split('\n').next().unwrap().split(',').collect(); let numbers: Vec<&str> = input.split('\n').next().unwrap().split(',').collect();
for i in numbers.iter() { for i in numbers.iter() {
println!("{}", i); println!("\t{}", i);
} }
let boards: Vec<&str> = input.split("\n\n").collect(); let boards: Vec<&str> = input.split("\n\n").collect();
println!("{}", boards.len()); println!("{}", boards.len());
for i in boards.iter() { for i in boards.iter() {
println!("{:?}", i); println!("\t{:?}", i);
} }
} }

View File

@ -2,8 +2,9 @@ use itertools::Itertools;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs; use std::fs;
fn main() { pub fn run() {
let input = fs::read_to_string("../input.txt").expect("Could not read file"); println!("Day 5:");
let input = fs::read_to_string("./inputs/day5.txt").expect("Could not read file");
let lines = input let lines = input
.lines() .lines()
@ -29,6 +30,6 @@ fn main() {
} }
for (key, value) in points.into_iter() { for (key, value) in points.into_iter() {
println!("({}, {}), {}", key.0, key.1, value); println!("\t({}, {}), {}", key.0, key.1, value);
} }
} }

14
src/main.rs Normal file
View File

@ -0,0 +1,14 @@
mod day1;
mod day2;
mod day3;
mod day4;
mod day5;
fn main() {
println!("Running Advent of Code 2021");
day1::run();
day2::run();
day3::run();
day4::run();
day5::run();
}