Parallel or Perpendicular?
Submissions: 1638   Accuracy:

43.53%

  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!

Given two force vectors, find out whether they are parallel, perpendicular or neither. Let the first vector be A = a1 i +a2 j + a3 k and the second vector be B = b1 i + b2 j + b3 k.

A.B = a1*b1 + a2*b2 + a3*b3

A x B = (a2*b3 - a3*b2) i - (a1*b3 - b1*a3) j + (a1*b2 - a2*b1) k

|A|^2 = a1^2 + a2^2 + a3^2

If A.B = 0, then A and B are perpendicular.

If |A X B|^2 = 0, then A and B are parallel.

Input:
The first line of input takes the number of test cases, T. Then T test cases follow. For each test case there will be two lines. The first line contains 3 space separated integers representing the components of the first force vector in x, y and z directions. The second line also contains 3 space separated integers representing the components of the second force vector in x, y and z directions.

Output:
Print 1 if the 2 vectors are parallel, 2 in case they are perpendicular, 0 otherwise.

Constraints:
1 <= T <= 100

-100 <= Component <= 100

Example:
Input:

3
3 2 1
6 4 2
4 6 1
1 -1 2
10 9 5
2 6 1

Output:
1
2
0

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arpan Kundu
Author: akundusaltlake


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.