Community Profile

Lenny Gorodetsky

32 total contributions since 2018

View details...

Contributions in
View by

Solved

Separate even from odd numbers in a vector - with a loop
*Using a loop*, rearrange a vector of integers such that the odd numbers appear at the beginning, and even numbers at the end. T...

mehr als ein Jahr ago

Solved

Separate even from odd numbers in a vector - without loops
*Without using loops*, rearrange a vector of integers such that the odd numbers appear at the beginning, and even numbers at the...

mehr als ein Jahr ago

Solved

Approximate the cosine function
Without using MATLAB trigonometric functions, calculate the cosine of an argument |x| to a precision of |0.0001| *Hint:* You ...

mehr als ein Jahr ago

Solved

Shuffle
Shuffle a vector by breaking it up to segments of |n| elements, and rearranging them in a reversed order. For example, the ve...

mehr als ein Jahr ago

Solved

Vector pop
Take |n| elements from the end of the vector |v| and return both the shorten vector |v| and the |n| elements in a separate vecto...

mehr als ein Jahr ago

Solved

Vector push
Append an element |x| to the end of the vector |v| and return both the extended vector and the new number of its elements. |x| c...

mehr als ein Jahr ago

Solved

How many unique Pythagorean triples?
For a given integer |n|, return all <https://en.wikipedia.org/wiki/Pythagorean_triple Pythagorean triples> that inlude numbers s...

mehr als ein Jahr ago

Solved

Pattern matching
Given a matrix, m-by-n, find all the rows that have the same "increase, decrease, or stay same" pattern going across the columns...

mehr als ein Jahr ago

Solved

Making change
Given an amount of currency, return a vector of this form: [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01] Example: Input a = ...

mehr als ein Jahr ago

Solved

Diagonal Pattern
For a positive integer |n|, return an |nXn| matrix |mat| such that the value of each element in row |i| and column |j| is given ...

mehr als ein Jahr ago

Solved

Remove the air bubbles
Given a matrix a, return a matrix b in which all the zeros have "bubbled" to the top. That is, any zeros in a given column shoul...

mehr als ein Jahr ago

Solved

Product of Each Column
Given a matrix |mat| with |n| columns, return a row vector |v| of length |n|, where every element in |v| is the product of the |...

mehr als ein Jahr ago

Solved

Triangle of numbers
Create a matrix with the integers from 1 to |n| arranged in a triangular shape. Every row |i| of the matrix contains |i| inte...

mehr als ein Jahr ago

Solved

Find the average of a random sequance
Write a function that generates random integers within a loop, and calculates the mean of the positive numbers only. At each ...

mehr als ein Jahr ago

Solved

How many Integers?
Count the integers in a given vector |v|. You *must* use a loop to count each element separately. Examples: Input: v...

mehr als ein Jahr ago

Solved

Remove the air bubbles from a vector
_*A reduced version of Problem 112*_ Given a column vector v, return a vector w in which all the zeros have "bubbled" to the ...

mehr als ein Jahr ago

Solved

Add a vector to a matrix
Given a matrix |mat| of size |mXn| and a row vector |v| of size |1Xs|, return a matrix with |m+1| rows that conatains |mat| over...

mehr als ein Jahr ago

Solved

Eye Squared
For a positive integer |n| create the identity matrix with |n| elements. In case it is not possible to produce an identity ma...

mehr als ein Jahr ago

Solved

Tax Calculator
Calculate the tax for a given income. 10% tax is paid for any income up to \$2,000. 20% tax is paid for additional income u...

mehr als ein Jahr ago

Solved

How many days in a month?
Return the number of days in a given month in 2017. If the input is not a valid month number, return -1. Examples: Input...

mehr als ein Jahr ago

Solved

Find the largest number
Given a vector v with 4 elements, find the largest number x. Example: Input: v = [4 7 1 6]; Output: x = 7; You mu...

mehr als ein Jahr ago

Solved

Rotate input square matrix 90 degrees CCW without rot90
Rotate input matrix (which will be square) 90 degrees counter-clockwise without using rot90,flipud,fliplr, or flipdim (or eval)....

mehr als ein Jahr ago

Solved

Reverse the elements of an array
Reverse the order of elements in an array: eg: input X = [ 1 2 3 ; 4 5 6 ; 7 8 9 ] o...

mehr als ein Jahr ago

Solved

surrounded matrix
With a given matrix A (size m x n) create a matrix B (size m+2 x n+2) so that the matrix A is surrounded by ones: A = [1 2 ...

mehr als ein Jahr ago

Solved

Back to basics 21 - Matrix replicating
Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, generate an output matrix that consists o...

mehr als ein Jahr ago

Solved

Write a function man that takes a row vector v and returns a matrix H as follows..
Write a function called man that takes a row vector v as an input and returns a matrix H whose first column consist of the eleme...

mehr als ein Jahr ago

Solved

frame of the matrix
Given the matrix M, return M without the external frame.

mehr als ein Jahr ago

Solved

Horizontal matrix sort
Given a matrix x with n rows and m columns, return a matrix y with n rows and 2m columns, such that every row in x is sorted fro...

fast 2 Jahre ago

Solved

Vertical matrix sort
Given a matrix x with n rows and m columns, return a matrix y with 2n rows and m columns, such that every column in x is sorted ...

fast 2 Jahre ago

Solved

Sum of adjacent elements in a vector
Given a vector v, return a vector s containting the sum of every two adjacent elements in the vector. Every element s(i) cont...

fast 2 Jahre ago