Solved


Find the nearest prime number
Happy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers. Given a positive in...

10 months ago

Solved


Is this is a Tic Tac Toe X Win?
For the game of Tic Tac Toe we will be storing the state of the game in a matrix M. For this game: We would store the state ...

10 months ago

Solved


unique with nan
input x = [2 NaN 3 5 NaN; 1 NaN 4 9 NaN; 8 -2 7 6 -2; 7 4 8 5 4]; output y_correct = [2 ...

10 months ago

Solved


Integer to boolean
Write a general function that will create the following conversation; Input is a column vector with integers Output is a b...

10 months ago

Solved


Low level NaN
I have a dataset. Columns represents different variables. A variable may start with NaN or any double type number. If it start...

10 months ago

Solved


Delete the rows in the middle
We will delete the rows in the middle and keep the first and the last rows. For example if input is [1 2 1 7 1 8 ...

10 months ago

Solved


Returning a "greater than" vector
Given a vector, v, return a new vector , vNew, containing only values > n. For example: v=[1 2 3 4 5 6] n=3 vNew =...

10 months ago

Solved


Sub-Diagonal Sum
Given a (m x n) matrix and a value r {1,-1}, change every element to the sum of the diagonal led by the element. r=1 > regular ...

10 months ago

Solved


Create matrix of replicated elements
Given an input element x, and the dimensions, (m, n) return a matrix of size m x n filled with element x. Example: Input: ...

10 months ago

Solved


A sequence of Ones
You are given number(s) with all digits - 1. Your answer will depend on the count of 1 in the given number, for example - x1...

10 months ago

Solved


Don't Try, give up and return NaN.
This is another version of <http://www.mathworks.com/matlabcentral/cody/problems/3107-try-and-catch-simple-example problem 3107....

10 months ago

Solved


MiniMax
Find the smallest value in array, which is the maximum of its row and column. Example: in array shown below are two numbers w...

10 months ago

Solved


find powers of two
find the unique, non-repeating, powers of 2 that sum to a given non-zero integer, n example: n = 23 result = [1 2 4 16] ...

10 months ago

Solved


Arrange vector in ascending order
Arrange a given vector in ascending order. input = [4 5 1 2 9]; output = [1 2 4 5 9];

10 months ago

Solved


Bleed non-zeros to the right
What a title! Yet, it says what I mean. You get a vector, some values and a lot of zeroes. Every zero is replaced by the firs...

10 months ago

Solved


Matrix to column conversion
Given a matrix of any size, convert it into a column vector. e.g A=[10 20 30; 40 50 60] then, B = [10; 40; ...

10 months ago

Solved


matrix of natural number
Given a number n, create an n-by-n matrix in which the integers from 1 to n^2 resides seially as shown in the examples below. ...

10 months ago

Solved


Reepeating numbers in array
Repeating numbers in array In = [1 0 0 0 2 0 0 0 3 0 0 0 0 0 5 0 0 0 0]. Out = [1 1 1 1 2 2 2 2 3 3 3 3 3 3 5 5 5 5 5].

10 months ago

Solved


Find Next Strictly Greater Element
Given an array of numbers, create a new array where each element represents the next strictly greater element to the right of th...

10 months ago

Solved


Number Persistence
A number's persistence is the number of steps required to reduce it to a single digit by multiplying all its digits to obtain a ...

10 months ago

Solved


Matlab Basics II - Count rows in a matrix
Write a function that returns that number of rows in a vector or matrix x example: x = [1; 2; 3] output = 3

10 months ago

Solved


Replace every 3rd element in a vector with 4
x is a vector of undetermined length You are to replace every 3rd element with the number 4, example: x = [11 23 34 43 2 3...

10 months ago

Solved


Matlab Basics II - Extract last 3 elements of a vector
Let x be a vector of unknown length, we are always interested in the last 3 numbers in the vector, write a function that gives t...

10 months ago

Solved


Normalizing a vector
Normalizing a set of values is an important operation in mathematics, consisting in affinely transforming a set of values in an ...

10 months ago

Solved


Sort by absolute value
Given a list of numbers, arrange them in ascending order based on their absolute values. For example, for the list [-30, -5, 1...

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

10 months ago

Solved


Min-Max digit

10 months ago

Solved


Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
The given function returns the index of the maximum value in a given matrix. such as X=[4,3,4,5,9,12,0,5] Ans= 6 if maxim...

10 months ago

Solved


End Digits

10 months 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 is n=4 th...

10 months ago

Load more