From a844f19446393d35e22f4aa3a89e97f54a1c65e3 Mon Sep 17 00:00:00 2001 From: Julius de Jeu Date: Fri, 17 Dec 2021 14:35:16 +0100 Subject: [PATCH] Change max and min --- src/day17.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/day17.rs b/src/day17.rs index cefedfe..82dc1e6 100644 --- a/src/day17.rs +++ b/src/day17.rs @@ -8,6 +8,8 @@ pub struct Day17 { y_max: i32, } +const Y_MAX: i32 = 100; + impl Day for Day17 { fn init(content: String) -> anyhow::Result { let c = content.split(' ').skip(1).collect::>(); @@ -23,9 +25,10 @@ impl Day for Day17 { } fn part1(&self) -> anyhow::Result { + println!("{}", self.y_max - self.y_min); let mut hits = Vec::new(); for dx in 0..=self.x_max { - for dy in -100..250 { + for dy in self.y_min..Y_MAX { let points = self.calc((dx, dy)); if self.hits(&points) { hits.push(max_height(&points).unwrap()); @@ -38,7 +41,7 @@ impl Day for Day17 { fn part2(&self) -> anyhow::Result { let mut hits = Vec::new(); for dx in 0..=self.x_max { - for dy in -100..250 { + for dy in self.y_min..Y_MAX { let points = self.calc((dx, dy)); if self.hits(&points) { hits.push((dx, dy));