Created
December 21, 2023 07:15
-
-
Save pahosler/2ce204704a1d7765928f75c054343ee4 to your computer and use it in GitHub Desktop.
advent of code rust template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get $TOKEN from .env | |
if [ -f .env ] | |
then | |
export "$(grep -v '^#' .env | xargs)" | |
fi | |
if [ -z "$1" ] | |
then | |
echo "usage: ./advent.sh 3" | |
exit | |
fi | |
# echo "$1 | |
if [ "$1" -gt 25 ] || [ "$1" -lt 0 ] | |
then | |
echo "ERROR: Must be two digits 0 -> 25" | |
exit | |
fi | |
curl -b "session=$TOKEN" "https://adventofcode.com/2023/day/$1/input" -o src/bin/day"$1".input | |
# All the template copying | |
cp template/main.rs src/bin/day"$1".rs | |
touch src/bin/day"$1".test1 | |
touch src/bin/day"$1".test2 | |
sed -i "s\day1\day$1\g" src/bin/day"$1".rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let input = include_str!("./day1.input"); | |
let output = part1(input); | |
dbg!(output); | |
let input = include_str!("./day1.input"); | |
let output = part2(input); | |
dbg!(output); | |
} | |
fn part1(input: &str) -> u32 { | |
0 | |
} | |
fn part2(input: &str) -> u32 { | |
0 | |
} | |
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn test_part_one() { | |
let input = include_str!("day1.test1"); | |
let output = part1(input); | |
assert!(output == 123); | |
} | |
#[test] | |
fn test_part_two() { | |
let input = include_str!("day1.test2"); | |
let output = part2(input); | |
assert!(output == 456); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment