Find common elements in matrix rows
Given a matrix, find all elements that exist in every row.
For example, given
A =
1 2 3 5
9 2 5 9
3 2 5 9
...
3 years 前
已解决
Fibonacci sequence
Calculate the nth Fibonacci number.
Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...
Examples:
Inpu...
3 years 前
已解决
Remove all the consonants
Remove all the consonants in the given phrase.
Example:
Input s1 = 'Jack and Jill went up the hill';
Output s2 is 'a ...
3 years 前
已解决
Remove any row in which a NaN appears
Given the matrix A, return B in which all the rows that have one or more <http://www.mathworks.com/help/techdoc/ref/nan.html NaN...
3 years 前
已解决
Counting Sequence
Given a vector x, find the "counting sequence" y.
A counting sequence is formed by "counting" the entries in a given sequence...
3 years 前
已解决
Return the 3n+1 sequence for n
A Collatz sequence is the sequence where, for a given number n, the next number in the sequence is either n/2 if the number is e...
3 years 前
已解决
De-dupe
Remove all the redundant elements in a vector, but keep the first occurrence of each value in its original location. So if
a =...
3 years 前
已解决
frame of the matrix
Given the matrix M, return M without the external frame.
3 years 前
已解决
Doubling elements in a vector
Given the vector A, return B in which all numbers in A are doubling. So for:
A = [ 1 5 8 ]
then
B = [ 1 1 5 ...
3 years 前
已解决
Flip the vector from right to left
Flip the vector from right to left.
Examples
x=[1:5], then y=[5 4 3 2 1]
x=[1 4 6], then y=[6 4 1];
Request not ...
Sum all integers from 1 to 2^n
Given the number x, y must be the summation of all integers from 1 to 2^x.
For instance if x=2 then y must be 1+2+3+4=10.
3 years 前
已解决
Select every other element of a vector
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...