1,024 total contributions since 2016

University of Toronto CS master's student.

martincarrington.com

Solved

Change the first and last diagonal element of the identity matrix to zero

Starting with the identity matrix, change first and last diagonal element to zero. Example If n=5 A = 0 0 ...

4 months ago

Solved

Replace values under a limit

For a vector x and number n, the goal is to find every element of x inferior to n and replace it by n. Example x= [ 1 2 3...

4 months ago

Solved

Add one raw in given matrix as shown in example

*Add one raw in given matrix as shown in example* A=[1 0;0 1]; X=[3 5]; Answer must be:[1 0; 0 1;3 5]

4 months ago

Solved

Additive persistence

Inspired by Problem 2008 created by Ziko. In mathematics, the persistence of a number is the *number of times* one must apply...

4 months ago

Solved

Replace secondary diagonal elements of a square array

Replace all the secondary diagonal elements of the square array A with the number n Example: A = [1 2 3 4 5 6 ...

4 months ago

Solved

Find the position of first minimum value in an integer array with numbers

If x = [2 6 4 9 10 3 1 5 1] the the output should be 7, because the first minimum value (1) lies at the 7th position.

4 months ago

Solved

Basics: Divide integers to get integer outputs in all cases

Divide integers a and b in such a way that output y is always an integer (in ceil manner)

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

4 months ago

Solved

Relative ratio of "1" in binary number

Input(n) is positive integer number Output(r) is (number of "1" in binary input) / (number of bits). Example: * n=0; r=...

4 months ago

Solved

Perimeter

Given a sequence of points forming a closed path (first and last points are coincident) return the perimeter value. For example...

4 months ago

Solved

Matlab Basics II - Extract last 3 elements of a vector

Let x be a vector of unknown length, we are always interested in the last 3 numbers in the vector, write a function that gives t...

4 months ago

Solved

Create an anti-identity matrix

Create an anti-identity matrix of given dimension. Examples n = 2 A = [0 1; 1 0] n = 3 A = [0 0 1; 0 1 0; 1 0 0...

4 months ago

Solved

Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)

For a row vector: V=[7 1 2 -3] there is one sign change (from 2 to -3). So, the function you write must return N=1. F...

4 months ago

Solved

Help the Patriots get to the Super Bowl

Given a football by the Patriots, return it to them with 2 psi less air in it. (The original psi is passed as a number to the...

4 months ago

Solved

Binary

Given a positive, integer n, create a function that returns the respective binary number in the form of a vector. Example: ...

4 months ago

Solved

Hard limit function

Classify x data as if x>=0 then y=1 if x<0 then y=0 Example x = [ -2 -1 0 1 2] y = [ 0 0 1 1 1]

4 months ago

Solved

Matlab Basics - Switching Assignments

Switch assignments for variables x and y, for example start with x = 1 and y = 3 end with y = 1 and x = 3 Do NOT simply r...

4 months ago

Solved

Matlab Basics II - Max & Index of Max

Write a function that takes a vector x, then returns both the max value in x and its location in the vector for example x ...

4 months ago

Solved

Matlab Basics II - Velocity of a particle

A particle is moving in space, such that it's velocity is given by: <<http://s30.postimg.org/5rf1xtvj5/cody1.png>> write a...

4 months ago

Solved

Let's see how peculiar we can get

The task is to multiply two numbers. But do it in the most peculiar possible way.

4 months ago

Solved

Colon operator of two vectors

You are given two vectors of equal length: VecStart, VecEnd Each vector contain a set of integers, where VecEnd(j)>=VecStar...

4 months ago

Solved

Find last zero for each column

Given a numeric array of arbitrary size, return the row index of the last zero for each column. If a column contains all nonzero...

4 months ago

Solved

Calculate area of sector

A=function(r,seta) r is radius of sector, seta is angle of sector, and A is its area. Area of sector A is defined as 0.5*(r^2...

4 months ago

Solved

Nearest

*Description* Find the value and index of the element in vector _x_ that is nearest to value _y_. _y_ should be able to be a ...

4 months ago

Solved

Narcissistic number ?

Inspired by Problem 2056 created by Ted. In recreational number theory, a narcissistic number is a number that is the sum of ...

4 months ago

Solved

MATCH THE STRINGS (2 CHAR) very easy

Match the given string based on first two characters on each string. For example A='harsa'; b='harish'; result '1' ...

4 months ago

Solved

Change the sign of even index entries of the reversed vector

change the signs of the even index entries of the reversed vector example 1 vec = [4 -1 -2 9] ans = [9 2 -1 -4] example2...

4 months ago