mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
Flip check order
This commit is contained in:
@@ -41,15 +41,14 @@ impl Hail {
|
|||||||
let x = b / a;
|
let x = b / a;
|
||||||
let y = a1 * x + b1;
|
let y = a1 * x + b1;
|
||||||
|
|
||||||
let t1 = (x - self.position[0] as f64) / self.speed[0] as f64;
|
if x < min || x > max || y < min || y > max {
|
||||||
let t2 = (x - other.position[0] as f64) / other.speed[0] as f64;
|
|
||||||
|
|
||||||
if t1 < 0.0 || t2 < 0.0 {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use the formula for X
|
let t1 = (x - self.position[0] as f64) / self.speed[0] as f64;
|
||||||
x >= min && x <= max && y >= min && y <= max
|
let t2 = (x - other.position[0] as f64) / other.speed[0] as f64;
|
||||||
|
|
||||||
|
t1 >= 0.0 && t2 >= 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(i: &[u8]) -> IResult<&[u8], Self> {
|
fn parse(i: &[u8]) -> IResult<&[u8], Self> {
|
||||||
|
|||||||
Reference in New Issue
Block a user