diff --git a/2023/day1/src/main.rs b/2023/day1/src/main.rs index 85fdd0d..57038b4 100644 --- a/2023/day1/src/main.rs +++ b/2023/day1/src/main.rs @@ -176,7 +176,7 @@ mod part2 { } fn main() { - let input = std::fs::read_to_string("./input").unwrap(); + let input = include_str!("../input"); let results: [u32; 2] = [part1::approaches(), part2::approaches()].map(|approaches| { input diff --git a/2023/day2/src/main.rs b/2023/day2/src/main.rs index 05d5741..054c273 100644 --- a/2023/day2/src/main.rs +++ b/2023/day2/src/main.rs @@ -206,7 +206,7 @@ fn limits() -> HashMap { } fn main() -> Result<(), String> { - let input = std::fs::read_to_string("./input").unwrap(); + let input = include_str!("../input"); match parse_input(&input) { Ok(input) => { @@ -224,7 +224,7 @@ fn main() -> Result<(), String> { nom::Needed::Size(n) => eprintln!("needed {n} more bytes"), }, NomErr::Error(e) | NomErr::Failure(e) => { - eprintln!("{}", nom::error::convert_error(input.as_str(), e)) + eprintln!("{}", nom::error::convert_error(input, e)) } }, }; @@ -261,7 +261,7 @@ mod tests { #[test] fn example_01() { - let input = std::fs::read_to_string("./example_01").unwrap(); + let input = include_str!("../example_01"); assert_eq!( count_possible_games(&parse_input(&input).unwrap(), &super::limits()).unwrap(), 8 @@ -270,7 +270,7 @@ mod tests { #[test] fn example_02() { - let input = std::fs::read_to_string("./example_02").unwrap(); + let input = include_str!("../example_02"); assert_eq!( minimum_cube_powered(&parse_input(&input).unwrap()).unwrap(), 2286 diff --git a/2023/day3/src/main.rs b/2023/day3/src/main.rs index 70277ca..719544c 100644 --- a/2023/day3/src/main.rs +++ b/2023/day3/src/main.rs @@ -156,7 +156,7 @@ fn part2(input: &str) -> usize { } fn main() { - let input = std::fs::read_to_string("./input").unwrap(); + let input = include_str!("../input"); println!("Part 1 : {}", part1(&input)); println!("Part 2 : {}", part2(&input));