Freecodecamp: The term "nVectors" in "Rosetta Code: Vector dot product" is undefined

Created on 19 Oct 2020  路  5Comments  路  Source: freeCodeCamp/freeCodeCamp


Describe your problem and how to reproduce it:
One of the test cases on the sidebar says dotProduct(...nVectors) should return 156000. nVectors is undefined

Additionally, I notice that there are some tests where the text value doesn't match the actual test string.

Add a Link to the page with the problem:
https://www.freecodecamp.org/learn/coding-interview-prep/rosetta-code/vector-dot-product

Tell us about your browser and operating system:

  • Browser Name: Firefox
  • Browser Version: 82
  • Operating System: Linux Mint
first timers only learn

Most helpful comment

Seems like an easy fix. So to be clear, we should do these to the tests:

  • Replace the text of the last test with the whole function + argument that is being used in the test
  • Align the text and testString so they match for the tests where they don't
  • Add backticks around functions/code in the text area

All 5 comments

The test in question:

- text: <code>dotProduct(...nVectors)</code> should return 156000.
    testString: assert.equal(dotProduct([ 0, 1, 2, 3, 4 ], [ 0, 2, 4, 6, 8 ], [ 0, 3, 6, 9, 12 ], [ 0, 4, 8, 12, 16 ], [ 0, 5, 10, 15, 20 ]), 156000);

Looking at the file, there are a few tests where the text value doesn't match the actual testString. These should probably be fixed. At the same time, the function calls in the text should be wrapped in <code> tags or backticks (`), I think.

Seems like an easy fix. So to be clear, we should do these to the tests:

  • Replace the text of the last test with the whole function + argument that is being used in the test
  • Align the text and testString so they match for the tests where they don't
  • Add backticks around functions/code in the text area

I have a branch that addresses these issues, but there is a further issue with the solution as the dot product is only defined for pairs of vectors, and any test with an odd number of vectors should either fail (since dot products should return scalars) or return a vector (the scalar product of the first vectors times the last one probably; but a dot product function really should return a scalar).

The original vector product challenge at Rosetta Code actually calls for the computation of all four vector products. There is already a 'Dot Product' challenge separate from this one (it only uses two vectors for input) and a 'Vector Cross Product' which has similar problems to this issue.

So, which solution is best for the dot product in this issue (my vote is two vectors only, followed distantly by any number of pairs that I implemented)? Should I go ahead and fix 'Vector Cross Product' and add 'Vector Triple Product' and 'Scalar Triple Product' to complete the set in one PR or split them into separate issues/PRs or just ignore the other two completely since they can be computed with the dot and cross products?

@jeremyagray Just to point out, this issue is labelled _first timers only_. So, unless someone else is fine with removing that, I would not say 4 days is unreasonably long to expect an issue labelled _first timers only_ to be resolved, before opening it up.

nVectors product has no sense It should be two or triple vectors product. as original vector product challenge at Rosetta Code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EthanDavis picture EthanDavis  路  3Comments

robwelan picture robwelan  路  3Comments

bagrounds picture bagrounds  路  3Comments

raisedadead picture raisedadead  路  3Comments

trashtalka3000 picture trashtalka3000  路  3Comments