Add template + setup script to get started quickly
This commit is contained in:
parent
387355f690
commit
68fa7fa6f5
8
2022/aoc_template/Cargo.toml
Normal file
8
2022/aoc_template/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "aoc_template"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
21
2022/aoc_template/src/main.rs
Normal file
21
2022/aoc_template/src/main.rs
Normal file
@ -0,0 +1,21 @@
|
||||
fn main() {
|
||||
// Use command line arguments to specify the input filename.
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() < 2 {
|
||||
panic!("Usage: ./main <input-file>\nNo input file provided. Exiting.");
|
||||
}
|
||||
|
||||
// Next, read the contents of the input file into a string for easier processing.
|
||||
let input = std::fs::read_to_string(&args[1]).expect("Error opening file");
|
||||
// Line-by-line processing is easiest.
|
||||
let input = input.lines();
|
||||
|
||||
// --- TASK BEGIN ---
|
||||
let mut result = 0;
|
||||
|
||||
for line in input {
|
||||
}
|
||||
|
||||
println!("Result: {}", result);
|
||||
}
|
||||
|
||||
12
2022/setup.sh
Executable file
12
2022/setup.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "$#" != "1" ]]; then
|
||||
echo " Usage: ./setup.sh <day>"
|
||||
echo "Example: ./setup.sh 13"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ident="day${1}-part1"
|
||||
cp -r aoc_template "$ident"
|
||||
sed -i -e "s/aoc_template/$ident/g" "$ident/Cargo.toml"
|
||||
Loading…
Reference in New Issue
Block a user