Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaxwood committed Aug 13, 2024
1 parent 07cc283 commit 35483b5
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/day24.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 35483b5

Please sign in to comment.