In the town of line segments two line segments can only become friends if their slopes are equal. Line segments are not smart enough to calculate their own or some other line segment's slope so they use a machine called the slopeFinder to check their compatibility. Recently someone stole the slopeFinder and now the line segments are upset because they cannot make new friends. The Mayor of the town has hired you to write a code to fix the crisis that their town is facing.
Input Format
Input Contains two line segments each on a line of its own. Each line segment is denoted by four integers Xa, Ya, Xb and Yb where (Xa,Ya) and (Xb, Yb) denote the two end points of the line segment.
Constraints
0 <= |Xa|,|Xb|,|Ya|,|Yb| <= 100
Output Format
Output "yes" if both the line segments have the same slope and "no" otherwise. (without the quotes).
Sample Input 0
0 0 1 1
1 0 2 1
Sample Output 0
yes
Sample Input 1
0 0 1 1
2 1 3 0
Sample Output 1
no
Source Code:
Xa,Ya,Xb,Yb=list(map(int,(input().split())))
Xp,Yp,Xq,Yq=list(map(int,(input().split())))
if Xb-Xa==0 or Xq-Xp==0:
print("no")
else:
slope1=float(Yb-Ya)//float(Xb-Xa)
slope2=float(Yq-Yp)//float(Xq-Xp)
if slope1 == slope2:
print("yes")
else:
print("no")
Comments
Post a Comment