Small changes to help go fast

This commit is contained in:
Daniel Flanagan 2022-12-04 02:11:08 -06:00
parent 7ffb3a0d9b
commit 3d926bfdb1
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
5 changed files with 24 additions and 6 deletions

View File

@ -2,6 +2,10 @@
name = "aoc2022"
version = "0.1.0"
[[bin]]
name = "scaffold"
path = "src/scaffold.rs"
[[bin]]
name = "day1"
path = "src/day1.rs"

View File

@ -15,7 +15,8 @@ url="https://adventofcode.com/$AOC_YEAR/day/$DAY/input"
cookie="$(cat "$HOME/.advent-of-code-session-cookie")"
mkdir -p "$(dirname "$f")"
if curl --fail-with-body -X GET "$url" -H "Cookie:$cookie" > "$f"; then
echo "Downloaded $url to $f"
cat "$f"
echo "Downloaded $url to $f - contents have been output to this terminal as well"
exit 0
else
echo "Error: curl failed"

View File

@ -8,6 +8,14 @@ pub fn day_input(day: u8) -> String {
let home_path = Path::new(home);
let path_buf = home_path.join(format!("./.cache/aoc2022/{0}.input", day));
let file_path = path_buf.to_str().unwrap();
if !path_buf.exists() {
eprintln!("Running input downloaded script with day arg {}...", day);
std::process::Command::new("sh")
.arg("./fetch_input.sh")
.arg(format!("{}", day))
.status()
.expect("fetch_input.sh failed");
}
fs::read_to_string(file_path).unwrap()
}

View File

@ -8,7 +8,7 @@ fn processed_input(input: &str) -> Input {
}
fn part1(input: &Input) -> Result {
0
100
}
fn part2(input: &Input) -> Result {
@ -16,7 +16,9 @@ fn part2(input: &Input) -> Result {
}
fn main() {
let input = processed_input(&common::day_input(5));
let input_text = common::day_input(5);
eprintln!("{}\n\nAbove is your input file.\n\n", input_text);
let input = processed_input(&input_text);
common::show_answers(&part1(&input), &part2(&input))
// common::show_both_answers(&both_parts(&input))
}
@ -36,5 +38,6 @@ mod tests {
let input = processed_input(TEST_INPUT);
assert_eq!(part1(&input), 0);
assert_eq!(part2(&input), 0);
// assert_eq!(both_parts(&input), (0, 0));
}
}

View File

@ -8,7 +8,7 @@ fn processed_input(input: &str) -> Input {
}
fn part1(input: &Input) -> Result {
0
100
}
fn part2(input: &Input) -> Result {
@ -16,9 +16,11 @@ fn part2(input: &Input) -> Result {
}
fn main() {
let input = processed_input(&common::day_input(panic!(
let input_text = common::day_input(panic!(
"PUT THE CORRECT DAY NUMBER HERE AND ADD bin TO Cargo.toml"
)));
));
eprintln!("{}\n\nAbove is your input file.\n\n", input_text);
let input = processed_input(&input_text);
common::show_answers(&part1(&input), &part2(&input))
// common::show_both_answers(&both_parts(&input))
}