parallel lines
There are different ways to express the equation of a line. Here's one way:
2x + 4y = 1
x + 2y = 1
The x and the y are always the same, but we can sub out variables for the three numbers:
ax + by = c
Now, we can just make a tuple with a, b, and c:
[a b c]
The first two lines represented in this form:
[2 4 1]
[1 2 1]
Okay! Now that we have a way to represent lines, your task is to write a function that takes two lines and tells us if they're parallel. Here's an example:
(parallel? [2 4 1] [1 2 1]) ;=> true
(parallel? [2 4 1] [4 2 1]) ;=> false
(parallel? [0 1 5] [0 1 5]) ;=> false ;; lines are not parallel to themselves
I'm looking forward to seeing the variety of answers.
Thanks to this site for the challenge idea where it is considered Medium level in Python.
Email submissions to eric@purelyfunctional.tv before July 5, 2020. You can discuss the submissions in the comments below.