Solved

The Answer to Life, the Universe, and Everything

A variation of a previous Hitchhiker's Guide to the Galaxy problem. *Inputs:* Life, the Universe, and Everything *Output:*...

3 months ago

Solved

Return 'on' or 'off'

When the input is true, return 'on', otherwise, return 'off'.

3 months ago

Solved

Sum the Digits of a Number

Given an integer, sum the digits repeatedly until you end up with a single value less than 10. For example, if you add the di...

3 months ago

Solved

sum of non-primes

The sum of the non-primes no larger than 10 is 1+4+6+8+9+10=38 Find the sum of all the positive non-prime integers that do no...

3 months ago

Solved

I've got the power! (Inspired by Project Euler problem 29)

Consider all integer combinations of a^b and b^a for the integer values 2 ≤ a ≤ 4 and 2 ≤ b ≤ 5: 2^2=4, 2^3=8, 2^4=16,...

3 months ago

Solved

Test if two numbers have the same digits

Given two integers _x1_ and _x2_, return |true| if the numbers written with no leading zeros contain the same digits. That is, t...

3 months ago

Solved

Subtract two positive numbers

Given a and b as a string, return b-a without using string to number conversion functions. a and b must to be a same size and b ...

3 months ago

Solved

Add two numbers

Calculate the sum of two numbers. Example input = [2 3] output = 5

3 months ago

Solved

Pi Estimate 2

Estimate Pi as described in the following link: <http://www.people.virginia.edu/~teh1m/cody/Pi_estimation2.pdf>

3 months ago

Solved

"mirror" matrix

Create n x 2n "mirror" matrix of this type: Examples For n = 2 m = [ 1 2 2 1 1 2 2 1 ] For n = 3 m = ...

3 months 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!

3 months ago

Solved

First non-zero element in each column

For a given matrix, calculate the index of the first non-zero element in each column. Assuming a column with all elements zero ...

3 months ago

Solved

How to multiply?

* Imagine you are in 3012 Anno Domini, when everyone must learn how to multiply, * and competing for the highly prestigious pos...

3 months 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

3 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];

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

3 months ago

Solved

Replace Vector Elements

Replace all elements in a vector which are equal to or smaller than zero with 0.1. Example: A = [1 2 3 -1 0 2 -3 -80]; ...

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

3 months ago

Solved

Getting the row and column location from a matrix

This is a basic MATLAB operation. It is for instructional purposes. --- You may already know how to get <http://www.mathwo...

3 months 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];

3 months ago

Solved

Multiply a column by a row

* Given a column vector C and and a row vector R. * Output a matrix M. * Every column of M equals to C multiplied by correspon...

3 months ago

Solved

Rotate a Matrix

Input a Matrix x, Output y is the matrix rotating x 90 degrees clockwise

3 months ago

Solved

Compute a dot product of two vectors x and y

x and y are input vectors, d is a number and contains their dot product

3 months ago

Solved

Determine Whether an array is empty

Input a matrix x, output y is TRUE if x is empty, otherwise FALSE.

3 months ago

Solved

How to add?

* Imagine you are in 2222 Anno Domini, when everyone must learn how to add, * and competing for the highly prestigious post of,...

3 months ago

Solved

Return unique values without sorting

If the input vector A is [42 1 1], the output value B must be the unique values [42 1] The *values of B are in the s...

3 months 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; ...

3 months ago

Solved

Sum of diagonal of a square matrix

If x = [1 2 4; 3 4 5; 5 6 7] then y should be the sum of the diagonals of the matrix y = 1 + 4 + 7 = 12

3 months ago

Solved

Back to basics 1 - Saving

Covering some basic topics I haven't seen elsewhere on Cody. Given an input variable 'x', save it to disk in a file named 'co...

3 months ago

Solved

polar inertia

given locations of a set of unit masses on complex plane, find polar moment of inerta about the origin. for example output 4 if ...

3 months ago