Is X a Fibonacci Matrix?
In honor of Cleve's new blog and post: <http://blogs.mathworks.com/cleve/2012/06/03/fibonacci-matrices/> Is X a Fibonacci ...

3年弱 前

"Look and say" sequence
What's the next number in this sequence? * [0] * [1 0] * [1 1 1 0] * [3 1 1 0] * [1 3 2 1 1 0] This a variant on the w...

3年弱 前

Sum of first n terms of a harmonic progression
Given inputs a, d and n, return the sum of the first n terms of the harmonic progression a, a/(1+d), a/(1+2d), a/(1+3d),....

3年弱 前

Return the Fibonacci Sequence
Write a code which returns the Fibonacci Sequence such that the largest value in the sequence is less than the input integer N. ...

3年弱 前

Solitaire Cipher
Implement the <http://en.wikipedia.org/wiki/Solitaire_(cipher) solitaire cipher>. Since this is from Wikipedia, I am capturin...

3年弱 前

Implement simple rotation cypher
If given a letter from the set: [abc...xyz] and a shift, implement a shift cypher. Example: 'abc' with a shi...

3年弱 前

Given a window, how many subsets of a vector sum positive
Given a vector: [1 0 -1 3 2 -3 1] and a window of 2, A sliding window would find: 1 + 0 = 1 0 - 1 = -1 ...

3年弱 前

How many trades represent all the profit?
Given a list of results from trades made: [1 3 -4 2 -1 2 3] We can add them up to see this series of trades made a profit ...

3年弱 前

Flag largest magnitude swings as they occur
You have a phenomenon that produces strictly positive or negative results. delta = [1 -3 4 2 -1 6 -2 -7]; Marching thr...

3年弱 前

Make a run-length companion vector
Given a vector x, return a vector r that indicates the run length of any value in x. Each element in r shows how many times the ...

3年弱 前

Spot the outlier
All points except for one lie on a line. Which one is the outlier? Example: You are given a list of x-y pairs in a column ...

3年弱 前

Find a subset that divides the vector into equal halves
Given a vector x, return the indices to elements that will sum to exactly half of the sum of all elements. Example: Inpu...

3年弱 前

How long is the longest prime diagonal?
Stanislaw Ulam once observed that if the counting numbers are <http://en.wikipedia.org/wiki/Ulam_spiral arranged in a spiral>, t...

3年弱 前

Find the biggest empty box
You are given a matrix that contains only ones and zeros. Think of the ones as columns in an otherwise empty floor plan. You wan...

3年弱 前

Magic is simple (for beginners)
Determine for a magic square of order n, the magic sum m. For example m=15 for a magic square of order 3.

3年弱 前

Make a random, non-repeating vector.
This is a basic MATLAB operation. It is for instructional purposes. --- If you want to get a random permutation of integer...

3年弱 前

Number of 1s in a binary string
Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input stri...

3年弱 前

Return the first and last character of a string
Return the first and last character of a string, concatenated together. If there is only one character in the string, the functi...

3年弱 前

Getting the indices from a vector
This is a basic MATLAB operation. It is for instructional purposes. --- You may already know how to <http://www.mathworks....

3年弱 前

Check if number exists in vector
Return 1 if number _a_ exists in vector _b_ otherwise return 0. a = 3; b = [1,2,4]; Returns 0. a = 3; b = [1,...

3年弱 前

Length of the hypotenuse
Given short sides of lengths a and b, calculate the length c of the hypotenuse of the right-angled triangle. <<http://upload....

3年弱 前

Generate a vector like 1,2,2,3,3,3,4,4,4,4
Generate a vector like 1,2,2,3,3,3,4,4,4,4 So if n = 3, then return [1 2 2 3 3 3] And if n = 5, then return [1 2 2...

3年弱 前

Return area of square
Side of square=input=a Area=output=b

3年弱 前

Maximum value in a matrix
Find the maximum value in the given matrix. For example, if A = [1 2 3; 4 7 8; 0 9 1]; then the answer is 9.

3年弱 前

Find the stride of the longest skip sequence
We define a _skip sequence_ as a regularly-spaced list of integers such as might be generated by MATLAB's <http://www.mathworks....

3年弱 前

Pangrams!
A pangram, or holoalphabetic sentence, is a sentence using every letter of the alphabet at least once. Example: Input s ...

3年弱 前

Counting Money
Add the numbers given in the cell array of strings. The strings represent amounts of money using this notation: \$99,999.99. E...

3年弱 前

Remove all the words that end with "ain"
Given the string s1, return the string s2 with the target characters removed. For example, given s1 = 'the main event' your ...

3年弱 前

Quote Doubler
Given a string s1, find all occurrences of the single quote character and replace them with two occurrences of the single quote ...

3年弱 前

Find relatively common elements in matrix rows
You want to find all elements that exist in greater than 50% of the rows in the matrix. For example, given A = 1 2 3 5 ...

3年弱 前