Coding+Challenges+
Coding+Challenges+
Suppose we are given a matrix A with dimensions of m* n. Given another vector say B of size 1-
by-2 which will indicate how much we want to enlarge each element of the matrix A. The first
value in the matrix B (called p), indicates how many rows we want to enlarge each element of A
and the second value in the matrix B (called q) indicate how many columns we want to enlarge
we want to enlarge each element of A. The resultant matrix called Enlarge_matrix will be of size
(m*p)-by-(n*q) in which each element of A has been replicated in p rows and q columns. Here is
an example of this
Suppose
A = [1 2 3;
456
7 8 9]
And
B = [3 2];
Then the result will look something like this
Enlarge_matrix = [ 1 1 2 2 3 3
112233
112233
445566
445566
445566
778899
778899
7 7 8 8 9 9]
Coding Challenge # 2
Generate a vector like 1,2,2,3,3,3,4,4,4,4, So if n = 3, then return
[1 2 2 3 3 3]
[1 2 2 3 3 3 4 4 4 4 5 5 5 5 5]
Coding Challenge # 3
You are given a square matrix containing positive integers. We want to determine if there is any
row or column containing the same number. For example:
111
423
234
Should be marked "true" because there are three consecutive ones in the first row.
However:
523
352
145
Is false, as we do not care about the three consecutive fives along the trace of the matrix. The
matrix will always be at least 3x3, but they can be larger.
Coding Challenge # 4
In this challenge we are going to create a vector from two input vectors A and B. The resultant
vector will contain the numbers specified between the two indexes at the same position in the
two vectors. For instance if A = [1 8 12] and B = [4 5 9] than the resultant matrix will contain the
following values. [1 2 3 4 8 7 6 5 12 11 10 9]
That is the we have A(1) = 1 and B(1) =4 therefore the first entries in the resultant matrix will be
from 1 to 4. Simillarly the second entry A(2) = 8 and B(2) = 5 therefore the resultant matrix will
have entries from 8 to 5 and so on.