Solved

Put m balls into n boxes (again)

According to <http://www.mathworks.com/matlabcentral/cody/problems/1516-put-m-balls-into-n-boxes Cody Problem 1516>, if I put 3 ...

8 months ago

Solved

Put m balls into n boxes

Can you find all the cases where, if I put 3 balls into 2 boxes the case is 1 1 1 1 1 2 1...

8 months ago

Solved

Get ranking of a combination looking for speed.

I have the numbers pulled without replacement from the set [1 2 3 4 5 6 7 8 9 10 11 12 13]; They are then ordered from least to...

8 months ago

Solved

Get ranking of a combination

I have the numbers pulled without replacement from the set [1 2 3 4 5 6 7 8 9 10 11 12 13]; They are then ordered from least to...

8 months ago

Solved

Combinations without using nchoosek

You have to generate a matrix with all possible combinations of n elements *taken 2* at a time, *without using nchoosek(1:n,2)* ...

8 months ago

Solved

Create Combination

Motivation: In many problems, we need to create combinations with the function nchoosek. In some cases, however, choices are lim...

8 months ago

Solved

Next lexicographic - permutation

Find next lexicographic - permutation (permutations as it would occur in a dictionary order). E.g: nextP('ABCD') = ABDC I...

8 months ago

Solved

Maximize the production in a plant within equipment capacity

The goal of a certain manufacturing company is to maximize its production of goods per day. In the production flow, there is a s...

8 months ago

Solved

Trace the path of a harmful chemical in an ecological network

An ecological network consists of the cycles of nature, such as the water cycle, the carbon cycle, the oxygen cycle, etc. Due to...

9 months ago

Solved

Four digit number ABCD reversal

write a MATLAB function to find the four-digit number ABCD when multiplied by 4 returns DCBA. The function takes an input x=4.

9 months ago

Solved

Number of o rderd pairs of integers (I,J) that can be formed.

Write a MATLAB function that calculates the number of ordered pairs of integers (I, J) that can be formed satisfying the condit...

9 months ago

Solved

Find the maximum two numbers of every column of a matrix

Find the maximum two numbers of every column of a matrix. Example: If we input a matrix A = [ 1 2 4 6 0 3 ...

9 months ago

Solved

Finding neighbors of [-1:1] in a matrix....

Hello All! Well I found this one fun to figure out, all you have to do is make a matrix of 1's or 0's (true or false) that sh...

9 months ago

Solved

Another colon problem

This is simple problem based on problems 555, 801, 1118, etc. Create an index vector from two input vectors. Example: ...

9 months ago

Solved

How unique?

Sometimes, when we check unique entries of vector we would like to know how many times each value occurs. Given vector of num...

9 months ago

Solved

return row and column indices given 2 values which define a range

Inspired by problem <http://www.mathworks.co.kr/matlabcentral/cody/problems/856-getting-the-indices-from-a-matrice> Inputs: - ...

9 months ago

Solved

Sum of odd numbers in a matrix

Find the sum of all the odd numbers in a matrix. Example x = [2 3 5 7 1 4 11] y = 27

9 months ago

Solved

Find the index of n in magic(n)

If input n=5, then magic(n) is 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22...

9 months ago

Solved

Largest territory

Determine whose territory is largest. If there are multiple numbers tied for the largest territory, return the smallest number. ...

9 months ago

Solved

counting groups!

This problem is about counting groups. Example If you have x: x = [0.8 0.8 0.8 0.3 0.3 0.4 0.5 0.6 0.6 0.9] then a...

9 months ago

Solved

Three...is a magic number.

Yes it is... It's a magic number... To help you get rid of that earworm, here's a new Cody problem. You are given a squar...

9 months ago

Solved

Time Expansion

How can you slow down any discrete-time signal? Example Input original signal x. x = [1 2 3 -1 -2 -5 -4] We want t...

9 months ago

Solved

remove single elements

Given a vector of integers, remove the elements that have appeared only once. The output elements should be in exact order as th...

9 months ago

Solved

Max Change in Consecutive Elements

If an array is given as input then find the index of consecutive elements that represent maximum change. Example: Input ...

9 months ago

Solved

expand intervals

You're given a row vector of an even number of monotonically increasing integers. Each pair of consecutive integers is the lower...

9 months ago

Solved

compress sequence into intervals

You're given a row vector of monotonically increasing integers most of which are consecutive. Find the upper and lower bounds of...

9 months ago

Solved

expand intervals vol.3

This is the next problem after <http://www.mathworks.co.uk/matlabcentral/cody/problems/2528 2528> and <http://www.mathworks.co.u...

9 months ago

Solved

expand intervals vol.2

Similar to problem <http://www.mathworks.co.uk/matlabcentral/cody/problems/2528 2528>. This is a more general case, when bounds ...

9 months ago

Solved

Top layer of a 3D pyramid

create a 3D pyramid(x,y,z) of ones(1) and zeros(0)...where pyramid part is denoted by one....nd find the top layer(x,y) of the p...

9 months ago

Solved

Luhn's Algorithm

Luhn's Algorithm is used as a checksum for credit card numbers or similar identifiers. It can detect single-digit changes and sw...

9 months ago