Solved

Set some matrix elements to zero

First get the maximum of each *row*, and afterwards set all the other elements to zero. For example, this matrix: 1 2 3 ...

mer än 6 år ago

Solved

Make an awesome ramp for a tiny motorcycle stuntman

Okay, given a vector, say v=[1 3 6 9 11], turn it into a matrix 'ramp' like so: m=[1 3 6 9 11; 3 6 9 11 0; 6 9 ...

mer än 6 år ago

Solved

surrounded matrix

With a given matrix A (size m x n) create a matrix B (size m+2 x n+2) so that the matrix A is surrounded by ones: A = [1 2 ...

mer än 6 år ago

Solved

Remove the air bubbles

Given a matrix a, return a matrix b in which all the zeros have "bubbled" to the top. That is, any zeros in a given column shoul...

mer än 6 år ago

Solved

Reverse the elements of an array

Reverse the order of elements in an array: eg: input X = [ 1 2 3 ; 4 5 6 ; 7 8 9 ] o...

mer än 6 år ago

Solved

Flip the main diagonal of a matrix

Given a n x n matrix, M, flip its main diagonal. Example: >> M=magic(5); >> flipDiagonal(M) 9 24 1 ...

mer än 6 år ago

Solved

Back to basics 23 - Triangular matrix

Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, return a matrix with all elements above a...

mer än 6 år ago

Solved

Remove NaN ?

input -> matrix (n*m) with at least one element equal to NaN; output -> matrix(p*m), the same matrix where we deleted the enti...

mer än 6 år ago

Solved

Back to basics 21 - Matrix replicating

Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, generate an output matrix that consists o...

mer än 6 år ago

Solved

Fibonacci-Sum of Squares

Given the Fibonacci sequence defined by the following recursive relation, * F_n = F_(n-1) + F_(n-2) * where F_0 = 0 and F_1 ...

mer än 6 år ago

Solved

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. ...

mer än 6 år ago

Solved

Project Euler: Problem 2, Sum of even Fibonacci

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te...

mer än 6 år ago

Solved

Alternating sum

Given vector x, calculate the alternating sum y = x(1) - x(2) + x(3) - x(4) + ...

mer än 6 år ago

Solved

Project Euler: Problem 6, Natural numbers, squares and sums.

The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ...

mer än 6 år ago

Solved

Triangle sequence

A sequence of triangles is constructed in the following way: 1) the first triangle is Pythagoras' 3-4-5 triangle 2) the s...

mer än 6 år ago

Solved

Find a Pythagorean triple

Given four different positive numbers, a, b, c and d, provided in increasing order: a < b < c < d, find if any three of them com...

mer än 6 år ago

Solved

Side of a rhombus

If a rhombus has diagonals of length x and x+1, then what is the length of its side, y? <<http://upload.wikimedia.org/wikipe...

mer än 6 år ago

Solved

Is this triangle right-angled?

Given any three positive numbers a, b, c, return true if the triangle with sides a, b and c is right-angled. Otherwise, return f...

mer än 6 år ago

Solved

Side of an equilateral triangle

If an equilateral triangle has area A, then what is the length of each of its sides, x? <<http://upload.wikimedia.org/wikipe...

mer än 6 år ago

Solved

Area of an Isoceles Triangle

An isosceles triangle has equal sides of length x and a base of length y. Find the area, A, of the triangle. <<http://upload...

mer än 6 år ago

Solved

Area of an equilateral triangle

Calculate the area of an equilateral triangle of side x. <<http://upload.wikimedia.org/wikipedia/commons/e/e0/Equilateral-tr...

mer än 6 år ago

Solved

Length of a short side

Calculate the length of the short side, a, of a right-angled triangle with hypotenuse of length c, and other short side of lengt...

mer än 6 år ago

Solved

Is this triangle right-angled?

Given three positive numbers a, b, c, where c is the largest number, return *true* if the triangle with sides a, b and c is righ...

mer än 6 år ago

Solved

Dimensions of a rectangle

The longer side of a rectangle is three times the length of the shorter side. If the length of the diagonal is x, find the width...

mer än 6 år ago

Solved

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....

mer än 6 år ago

Solved

radius of a spherical planet

You just measured its surface area, that is the input.

mer än 6 år ago

Solved

Distance walked 1D

Suppose you go from position 7 to 10 to 6 to 4. Then you have walked 9 units of distance, since 7 to 10 is 3 units, 10 to 6 is 4...

mer än 6 år ago

Solved

Target sorting

Sort the given list of numbers |a| according to how far away each element is from the target value |t|. The result should return...

mer än 6 år ago

Solved

The Hitchhiker's Guide to MATLAB

Output logical "true" if the input is the answer to life, the universe and everything. Otherwise, output logical "false".

mer än 6 år ago