Solved

Love triangles

Given a vector of lengths [a b c], determines whether a triangle with non-zero area (in two-dimensional Euclidean space, smarty!...

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

surface of a spherical planet

you just discovered its circumference, that is the input.

7 years ago

Solved

Balanced number

Given a positive integer find whether it is a balanced number. For a balanced number the sum of first half of digits is equal to...

7 years ago

Solved

Project Euler: Problem 1, Multiples of 3 and 5

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23...

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

7 years ago

Solved

Make a 1 hot vector

Make a vector of length _N_ that consists of all zeros except at index _k_, where it has the value 1. Example: Input ...

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

Convert a vector into a number

This is a sub problem related to this problem: <http://www.mathworks.com/matlabcentral/cody/problems/621-cryptomath-addition>...

7 years ago

Solved

Get the length of a given vector

Given a vector x, the output y should equal the length of x.

7 years ago

Solved

Kaprekar Steps

6174 is the <http://en.wikipedia.org/wiki/6174_%28number%29 Kaprekar constant>. All natural numbers less than 10,000 (except som...

7 years ago

Solved

All capital?

Are all the letters in the input string capital letters? Examples: 'MNOP' -> 1 'MN0P' -> 0

7 years ago

Solved

Make one big string out of two smaller strings

If you have two small strings, like 'a' and 'b', return them put together like 'ab'. 'a' and 'b' => 'ab' For extra ...

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

Convert from Base 10 to base 5

Convert the input number from base 10 into base 5: for example: if a(in base 10)= 5 then a(in base 5)= 10

7 years ago

Solved

Cell joiner

You are given a cell array of strings and a string delimiter. You need to produce one string which is composed of each string fr...

7 years ago

Solved

What's Your BMI?

Find the body mass index. For reference, please refer to Wikipedia here: <http://en.wikipedia.org/wiki/Body_mass_index body ...

7 years ago

Solved

Pangrams!

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

7 years ago

Solved

Given an unsigned integer x, find the largest y by rearranging the bits in x

Given an unsigned integer x, find the largest y by rearranging the bits in x. Example: Input x = 10 Output y is 12 ...

7 years ago

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

Return the largest number that is adjacent to a zero

This example comes from Steve Eddins' blog: <http://blogs.mathworks.com/steve/2009/05/27/learning-lessons-from-a-one-liner/ Lear...

7 years ago

Solved

Vector Linear sum: (p1-m1)V1+(p2-m2)V2+...(pK-mk)Vk

Calculate the sum of a Vector times coefficients expressed as two strings. Example: Normal representation [ a b c ], [ p1 ...

7 years ago

Solved

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

7 years ago

Solved

Replace NaNs with the number that appears to its left in the row.

Replace NaNs with the number that appears to its left in the row. If there are more than one consecutive NaNs, they should all ...

7 years ago

Solved

Calculate the height of an object dropped from the sky

Assume that an object is dropped from 1000 meters above the surface of the earth at time t=0. The object is dropped such that t...

7 years ago

Solved

Nearest Numbers

Given a row vector of numbers, find the indices of the two nearest numbers. Examples: [index1 index2] = nearestNumbers([2 5 3...

7 years ago

Solved

distance between two points

compute distance between two points,where it is in Cartesian, Polar or Spherical coordinates.

7 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

7 years ago