diff --git a/lib/day24.rb b/lib/day24.rb index e765258..a8674cd 100644 --- a/lib/day24.rb +++ b/lib/day24.rb @@ -39,11 +39,7 @@ def intersection_point(other_line) end def to_s - if @slope == Float::INFINITY - "x = #{@x_intercept}" - else - "y = #{@slope}x + #{@y_intercept}" - end + "(#{@x}, #{@y})" end protected @@ -78,11 +74,8 @@ def part1 x, y = part.intersection_point(other_part) # check if the intersection point is in the test grid if x.between?(@min, @max) && y.between?(@min, @max) - # check if the intersection point is in the future - if x > part.x - puts "Intersection point: #{x}, #{y}" - result << part.intersection_point(other_part) - end + puts "Intersection point: #{x}, #{y} for lines #{part} and #{other_part}" + result << part.intersection_point(other_part) end end end