Improve scaffolding

This commit is contained in:
Daniel Flanagan 2022-12-04 01:55:11 -06:00
parent 1fc8a7f4fe
commit d79c2756da
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
4 changed files with 62 additions and 35 deletions

View file

@ -22,4 +22,12 @@ path = "src/day3.rs"
name = "day4"
path = "src/day4.rs"
[[bin]]
name = "day4-alt1"
path = "src/day4-alt1.rs"
[[bin]]
name = "day5"
path = "src/day5.rs"
[dependencies]

View file

@ -11,10 +11,13 @@ pub fn day_input(day: u8) -> String {
fs::read_to_string(file_path).unwrap()
}
#[allow(dead_code)]
pub fn show_answers(answer1: &impl Debug, answer2: &impl Debug) {
println!("Part 1: {:?}", answer1);
println!("Part 2: {:?}", answer2);
}
#[allow(dead_code)]
pub fn show_both_answers((a, b): &(impl Debug, impl Debug)) {
show_answers(a, b)
}

View file

@ -1,18 +1,29 @@
mod common;
type Input = String;
type Result = usize;
fn processed_input(input: &str) -> Input {
input.to_owned()
}
fn part1(input: &Input) -> Result {
0
}
fn part2(input: &Input) -> Result {
0
}
fn main() {
let input = common::day_input(5);
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
let input = processed_input(&common::day_input(5));
common::show_answers(&part1(&input), &part2(&input))
// common::show_both_answers(&both_parts(&input))
}
fn part1(input: &str) -> i32 {
0
}
fn part2(input: &str) -> i32 {
0
}
// fn both_parts(input: &Input) -> (Result, Result) {
// (0, 0)
// }
#[cfg(test)]
mod tests {
@ -21,12 +32,9 @@ mod tests {
const TEST_INPUT: &str = "";
#[test]
fn test_part1() {
assert_eq!(part1(TEST_INPUT), 0)
}
#[test]
fn test_part2() {
assert_eq!(part2(TEST_INPUT), 0)
fn test() {
let input = processed_input(TEST_INPUT);
assert_eq!(part1(&input), 0);
assert_eq!(part2(&input), 0);
}
}

View file

@ -1,20 +1,31 @@
mod common;
type Input = &str;
type Input = String;
type Result = usize;
fn processed_input(input: &str) -> Input {
input.to_owned()
}
fn part1(input: &Input) -> Result {
0
}
fn part2(input: &Input) -> Result {
0
}
fn main() {
let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE"));
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
let input = processed_input(&common::day_input(panic!(
"PUT THE CORRECT DAY NUMBER HERE AND ADD bin TO Cargo.toml"
)));
common::show_answers(&part1(&input), &part2(&input))
// common::show_both_answers(&both_parts(&input))
}
fn part1(input: &str) -> i32 {
0
}
fn part2(input: &str) -> i32 {
0
}
// fn both_parts(input: &Input) -> (Result, Result) {
// (0, 0)
// }
#[cfg(test)]
mod tests {
@ -23,12 +34,9 @@ mod tests {
const TEST_INPUT: &str = "";
#[test]
fn test_part1() {
assert_eq!(part1(TEST_INPUT), 0)
}
#[test]
fn test_part2() {
assert_eq!(part2(TEST_INPUT), 0)
fn test() {
let input = processed_input(TEST_INPUT);
assert_eq!(part1(&input), 0);
assert_eq!(part2(&input), 0);
}
}