7 kyu

Orthogonal Vectors

126 of 1,869user3043623

Description:

Suppose I have two vectors: (a1, a2, a3, ..., aN) and (b1, b2, b3, ..., bN). The dot product between these two vectors is defined as:

a1*b1 + a2*b2 + a3*b3 + ... + aN*bN

The vectors are classified as orthogonal if the dot product equals zero.

Complete the function that accepts two sequences as inputs and returns true if the vectors are orthogonal, and false if they are not. The sequences will always be correctly formatted and of the same length, so there is no need to check them first.

Examples

[1, 1, 1], [2, 5, 7]        --> false
[1, 0, 0, 1], [0, 1, 1, 0]  --> true
Physics
Mathematics
Algorithms

Stats:

CreatedMay 5, 2014
PublishedMay 5, 2014
Warriors Trained2561
Total Skips40
Total Code Submissions3898
Total Times Completed1869
Ruby Completions126
JavaScript Completions752
CoffeeScript Completions12
Python Completions1013
Haskell Completions23
Java Completions38
Total Stars18
% of votes with a positive feedback rating92% of 343
Total "Very Satisfied" Votes293
Total "Somewhat Satisfied" Votes45
Total "Not Satisfied" Votes5
Total Rank Assessments30
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • user3043623 Avatar
  • raulbc777 Avatar
  • matt c Avatar
  • anter69 Avatar
  • donaldsebleung Avatar
  • hobovsky Avatar
  • albertogcmr Avatar
  • QKiryu Avatar
  • tobeannouncd Avatar
Ad