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

plus de 8 ans ago

Problem

Number of 1s in a binary string

Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input stri...

plus de 8 ans ago | 15

Solved

Number of 1s in a binary string

Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input stri...

plus de 8 ans ago

Solved

Geometric series

Find the sum, given the first term t1, the common ratio r, and number of terms n. Examples If input t1=1, r=1, n=7 the...

plus de 8 ans ago

Solved

Summing digits

Given n, find the sum of the digits that make up 2^n. Example: Input n = 7 Output b = 11 since 2^7 = 128, and 1 + ...

plus de 8 ans ago

Solved

Count photos

Given n people, everyone must have pictures taken with everyone, each photo includes only two persons, please count the total nu...

plus de 8 ans ago

Solved

Is this matrix orthogonal?

Given a square matrix, a, determine whether it is orthogonal. INPUT: a, a n x n matrix OUTPUT: true or false

plus de 8 ans ago

Solved

Create a square matrix of multiples

Given an input, N, output a matrix N x N with each row containing multiples of the first element of each row. This also applies...

plus de 8 ans ago

Solved

Find the largest value in the 3D matrix

Given a 3D matrix, A, find the largest value. E.g. >> A = 1:9; >> A=reshape(A,[3 1 3]); >> islargest(A) ans = 9

plus de 8 ans ago

Solved

Swap the first and last columns

Flip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All oth...

plus de 8 ans ago

Solved

Create times-tables

At one time or another, we all had to memorize boring times tables. 5 times 5 is 25. 5 times 6 is 30. 12 times 12 is way more th...

plus de 8 ans ago

Solved

Increment a number, given its digits

Take as input an array of digits (e.g. x = [1 2 3]) and output an array of digits that is that number "incremented" properly, (i...

plus de 8 ans ago

Solved

Find the numeric mean of the prime numbers in a matrix.

There will always be at least one prime in the matrix. Example: Input in = [ 8 3 5 9 ] Output out is 4...

plus de 8 ans ago

Solved

Project Euler: Problem 7, Nth prime

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the Nth prime nu...

plus de 8 ans ago

Solved

So many choices

For inputs _n_ and _k_ (in that order), output the number of ways that k objects can be chosen from amongst n distinct objects. ...

plus de 8 ans ago

Solved

Factorize THIS, buddy

List the prime factors for the input number, in decreasing order. List each factor only once, even if the factorization includes...

plus de 8 ans 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.

plus de 8 ans ago

Problem

Sum of first n terms of a harmonic progression

Given inputs a, d and n, return the sum of the first n terms of the harmonic progression a, a/(1+d), a/(1+2d), a/(1+3d),....

plus de 8 ans ago | 2

Solved

Most nonzero elements in row

Given the matrix a, return the index r of the row with the most nonzero elements. Assume there will always be exactly one row th...

plus de 8 ans 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

plus de 8 ans ago

Solved

Which values occur exactly three times?

Return a list of all values (sorted smallest to largest) that appear exactly three times in the input vector x. So if x = [1 2...

plus de 8 ans 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...

plus de 8 ans ago

Solved

Sum of first n terms of a harmonic progression

Given inputs a, d and n, return the sum of the first n terms of the harmonic progression a, a/(1+d), a/(1+2d), a/(1+3d),....

plus de 8 ans 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...

plus de 8 ans ago

Solved

First N Perfect Squares

*Description* Return the first N perfect squares *Example* input = 4; output = [ 1 4 9 16 ];

plus de 8 ans ago

Solved

Back to basics 11 - Max Integer

Covering some basic topics I haven't seen elsewhere on Cody. Return the largest positive integer MATLAB can handle.

plus de 8 ans ago

Solved

Back to basics 12 - Input Arguments

Covering some basic topics I haven't seen elsewhere on Cody. Return a value equal to the number of input arguments to the fun...

plus de 8 ans 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...

plus de 8 ans 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 = ...

plus de 8 ans ago