diff options
Diffstat (limited to '2023/day24.rs')
| -rw-r--r-- | 2023/day24.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/2023/day24.rs b/2023/day24.rs index 69f0b74..09274c7 100644 --- a/2023/day24.rs +++ b/2023/day24.rs @@ -51,10 +51,10 @@ fn crosses_xy(s1: &Stone, s2: &Stone, coord_min: f64, coord_max: f64) -> bool { fn main() { let args: Vec<String> = env::args().collect(); - let filename = if args.len() == 1 { - "in/".to_owned() + args[0].split('/').last().unwrap() + ".pzl" + let (filename, testinput) = if args.len() == 1 { + ("in/".to_owned() + args[0].split('/').last().unwrap() + ".pzl", false) } else { - args[1].clone() + (args[1].clone(), true) }; let mut f = File::open(filename).expect("cannot open file"); let mut content = String::new(); @@ -70,10 +70,11 @@ fn main() { }); } - let coord_min = 200000000000000.0; - let coord_max = 400000000000000.0; - // let coord_min = 7.0; - // let coord_max = 27.0; + let (coord_min, coord_max) = if testinput { + (7.0, 27.0) + } else { + (200000000000000.0, 400000000000000.) + }; let mut cross: Vec<bool> = Vec::new(); for i in 0..ss.len() { @@ -81,7 +82,6 @@ fn main() { cross.push(crosses_xy(&ss[i], &ss[j], coord_min, coord_max)); } } - let res1 = cross.iter().filter(|x| **x).fold(0, |x, _| x + 1); let mut res2 = 0; |
