move to include_str!() macro for all data
Move away from I/O to just including the data in the program via macro.
This commit is contained in:
5 files changed
+20
-31
No files matched your search
+3
-4
@@ -1,4 +1,3 @@
|
||||
use crate::utils::read_file;
|
||||
use anyhow::Result;
|
||||
|
||||
fn strings_to_ints(s: &str) -> Vec<usize> {
|
||||
@@ -89,7 +88,7 @@ fn diagnose_lifesupport(s: &str) -> usize {
|
||||
}
|
||||
|
||||
pub(crate) fn run() -> Result<(usize, usize)> {
|
||||
let input = read_file("data/day03.txt")?;
|
||||
let input = include_str!("../data/day03.txt");
|
||||
Ok((diagnose_power(&input), diagnose_lifesupport(&input)))
|
||||
}
|
||||
|
||||
@@ -99,14 +98,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_example() {
|
||||
let input = read_file("data/day03-test.txt").unwrap();
|
||||
let input = include_str!("../data/day03-test.txt");
|
||||
assert_eq!(diagnose_power(&input), 198);
|
||||
assert_eq!(diagnose_lifesupport(&input), 230);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_my_data() {
|
||||
let input = read_file("data/day03.txt").unwrap();
|
||||
let input = include_str!("../data/day03.txt");
|
||||
assert_eq!(diagnose_power(&input), 4191876);
|
||||
// assert_eq!(follow_course(&input), 2070300);
|
||||
// assert_eq!(follow_course_better(&input), 2078985210);
|
||||
|
||||
Reference in new issue
Block a user