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:
swaits committed 2021-12-04 21:59:10 -07:00
1 parent 5a32230b8c
commit 77a9b9fcc5
5 files changed
+20 -31

No files matched your search

+3 -4
View File
@@ -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);