question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
moT01commented, Oct 28, 2020

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
1reaction
jeremyagraycommented, Nov 1, 2020

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dot product - Rosetta Code
Task Create a function/use an in-built function, to compute the dot product, also known as the scalar product of two vectors.
Read more >
Vector products - Rosetta Code
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
Read more >
Undefined values - Rosetta Code
A scalar variable (numeric or string) cannot have an 'undefined' value; if an attempt is made to read a variable which has never...
Read more >
Variables - Rosetta Code
Variable declaration. Variables local to a function ( i and j in the example below) can be declared just before the body of...
Read more >
Vector - Rosetta Code
Task Implement a Vector class (or a set of functions) that models a Physical Vector. The four basic operations and a pretty print...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found