Solved


Bottles of beer
Given an input number representing the number of bottles of beer on the wall, output how many are left if you take one down and ...

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

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

7 years ago

Solved


Back to basics 22 - Rotate a matrix
Covering some basic topics I haven't seen elsewhere on Cody. Rotate the input matrix 90 degrees counterclockwise (e.g. [1 2; ...

7 years ago

Solved


Rotate a Matrix by 90 degrees
Rotate a Matrix by 90 degrees Example: If the input is: X = 1 2 3 4 5 6 7 8 9 ...

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

7 years ago

Solved


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

7 years ago

Solved


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

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

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

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

7 years ago

Solved


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.

7 years ago

Solved


Tell me the slope
Tell me the slope, given a vector with horizontal run first and vertical rise next. Example input: x = [10 2];

7 years ago

Solved


How to find the position of an element in a vector without using the find function
Write a function posX=findPosition(x,y) where x is a vector and y is the number that you are searching for. Examples: fin...

7 years ago

Solved


Unit Matrix
Given n, you should return an n-by-n unit matrix. Example: If input is n=2 then A = [ 1 0 0 1 ] If input ...

7 years ago

Solved


Replace May with April
For instance, if the input is input_str = 'The flowers may bloom in April'; then the output is output_str = 'The flo...

7 years ago

Solved


Reverse a matrix
Its simple. You have to reverse a given matrix.

7 years ago

Solved


Create a two dimensional zero matrix
You have to create a zero matrix of size (mxn) whose inputs are m and n and the elements of your matrix should be zeros. Exam...

7 years ago

Solved


Matlab Basics - Convert a row vector to a column vector
Write a script to convert a row (e.g. x = [1 2 3]) to a column (e.g. y = [1;2;3]), your script should be able to do this for any...

7 years ago

Solved


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

7 years ago

Solved


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.

7 years ago

Solved


Back to basics 8 - Matrix Diagonals
Covering some basic topics I haven't seen elsewhere on Cody. Given an input vector of numbers, output a square array with the...

7 years ago

Solved


Back to basics 6 - Column Vector
Covering some basic topics I haven't seen elsewhere on Cody. Given an input vector, output true or false whether it is a colu...

7 years ago

Solved


Find the sum of the elements in the "second" diagonal
Find the sum of the elements in the diagonal that starts at the top-right corner and ends at the bottom-left corner.

7 years ago

Solved


Too mean-spirited
Find the mean of each consecutive pair of numbers in the input row vector. For example, x=[1 2 3] ----> y = [1.5 2.5] x=[1...

7 years ago

Solved


Produce a sine wave
Produce a sine wave with amplitude 3: <<http://blogs.mathworks.com/images/seth/cody/sine-eqn.png>>

7 years ago

Solved


Number of Horns on a unicorn!
Calculate the number of horns on a *unicorn*! And I'm talking about a unicorn with not more than one horn on it!

8 years ago

Solved


Assigning a sum
* Write a statement that assigns numCoins with numNickels + numDimes.

8 years ago

Solved


Sorted highest to lowest?
Return 1 if the input is sorted from highest to lowest, 0 if not. Example: 1:7 -> 0 [7 5 2] -> 1

8 years ago

Solved


Swap the input arguments
Write a two-input, two-output function that swaps its two input arguments. For example: [q,r] = swap(5,10) returns q = ...

8 years ago

Load more