Small changes to help go fast
This commit is contained in:
parent
7ffb3a0d9b
commit
3d926bfdb1
|
@ -2,6 +2,10 @@
|
||||||
name = "aoc2022"
|
name = "aoc2022"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "scaffold"
|
||||||
|
path = "src/scaffold.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "day1"
|
name = "day1"
|
||||||
path = "src/day1.rs"
|
path = "src/day1.rs"
|
||||||
|
|
|
@ -15,7 +15,8 @@ url="https://adventofcode.com/$AOC_YEAR/day/$DAY/input"
|
||||||
cookie="$(cat "$HOME/.advent-of-code-session-cookie")"
|
cookie="$(cat "$HOME/.advent-of-code-session-cookie")"
|
||||||
mkdir -p "$(dirname "$f")"
|
mkdir -p "$(dirname "$f")"
|
||||||
if curl --fail-with-body -X GET "$url" -H "Cookie:$cookie" > "$f"; then
|
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
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Error: curl failed"
|
echo "Error: curl failed"
|
||||||
|
|
|
@ -8,6 +8,14 @@ pub fn day_input(day: u8) -> String {
|
||||||
let home_path = Path::new(home);
|
let home_path = Path::new(home);
|
||||||
let path_buf = home_path.join(format!("./.cache/aoc2022/{0}.input", day));
|
let path_buf = home_path.join(format!("./.cache/aoc2022/{0}.input", day));
|
||||||
let file_path = path_buf.to_str().unwrap();
|
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()
|
fs::read_to_string(file_path).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ fn processed_input(input: &str) -> Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part1(input: &Input) -> Result {
|
fn part1(input: &Input) -> Result {
|
||||||
0
|
100
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part2(input: &Input) -> Result {
|
fn part2(input: &Input) -> Result {
|
||||||
|
@ -16,7 +16,9 @@ fn part2(input: &Input) -> Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
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_answers(&part1(&input), &part2(&input))
|
||||||
// common::show_both_answers(&both_parts(&input))
|
// common::show_both_answers(&both_parts(&input))
|
||||||
}
|
}
|
||||||
|
@ -36,5 +38,6 @@ mod tests {
|
||||||
let input = processed_input(TEST_INPUT);
|
let input = processed_input(TEST_INPUT);
|
||||||
assert_eq!(part1(&input), 0);
|
assert_eq!(part1(&input), 0);
|
||||||
assert_eq!(part2(&input), 0);
|
assert_eq!(part2(&input), 0);
|
||||||
|
// assert_eq!(both_parts(&input), (0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ fn processed_input(input: &str) -> Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part1(input: &Input) -> Result {
|
fn part1(input: &Input) -> Result {
|
||||||
0
|
100
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part2(input: &Input) -> Result {
|
fn part2(input: &Input) -> Result {
|
||||||
|
@ -16,9 +16,11 @@ fn part2(input: &Input) -> Result {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
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"
|
"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_answers(&part1(&input), &part2(&input))
|
||||||
// common::show_both_answers(&both_parts(&input))
|
// common::show_both_answers(&both_parts(&input))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue