Quiz#10

Wish Lists

Obviously to implement with vectors (or arrays if you like) for the C++ groups and lists for the Python groups. Feel free to do multiple versions for extra fun, I am sure that is what these stormtroopers are doing now.

Perhaps you should do the same!

Question 1

Create a function called findThrees that receives as a parameter a vector/array/list of numbers and returns the sum of all numbers in that vector/array/list that are evenly divisible by 3.

So if the vector/array/list was: {0,4,2,6,9,8,3,12}, the function would return 30
since  (0+6+9+3+12) is 30.

Question 2

In mathematics, the dot product, or scalar product (or sometimes inner product in the context of Euclidean space), is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors) and returns a single number.
Algebraically, it is the sum of the products of the corresponding entries of the two sequences of numbers”

(source http://en.wikipedia.org/wiki/Dot_product )

Create a function called dotProduct that receives two vectors/arrays/lists of numbers (say v1 and v2). The function returns what is the dot product of the two vectors/arrays/lists.

Note1: If using vectors/lists, you must check that both vectors are the same size. If not, your function should print an error message (“Not same size vectors”) and return -1
Note2: If using arrays, you need to pass a third parameter which is the size of the arrays, you can assume both arrays are that same size.

Example. If the input is {2,4,5,6} and {1,2,3,4} the result will be 49 since
(2*1)+(4*2)+(5*3)+(6*4) is 49

Scoring

  • 10 points if submitted before midnight on April 24.
  • 9 points if submitted before midnight April 25
  • 8 points if submitted before midnight April 26
  • etc (1 point less for each day later)

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #QUIZ10 on your post so our blog hub picks that up.

You MUST include your code as links to GitHub.

 

 

CC BY 4.0 Quiz#10 by Ken Bauer is licensed under a Creative Commons Attribution 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.