Community Profile

# Thinh Nguyen

##### Last seen: environ 2 mois ago
52 total contributions since 2021

View details...

Contributions in
View by

Solved

Check if number exists in vector
Return 1 if number _a_ exists in vector _b_ otherwise return 0. a = 3; b = [1,2,4]; Returns 0. a = 3; b = [1,...

2 mois ago

Solved

Find the longest sequence of 1's in a binary sequence.
Given a string such as s = '011110010000000100010111' find the length of the longest string of consecutive 1's. In this examp...

2 mois ago

Solved

Find all elements less than 0 or greater than 10 and replace them with NaN
Given an input vector x, find all elements of x less than 0 or greater than 10 and replace them with NaN. Example: Input ...

2 mois ago

Solved

Return the largest number that is adjacent to a zero
This example comes from Steve Eddins' blog: <http://blogs.mathworks.com/steve/2009/05/27/learning-lessons-from-a-one-liner/ Lear...

2 mois ago

Solved

Balanced number
Given a positive integer find whether it is a balanced number. For a balanced number the sum of first half of digits is equal to...

2 mois ago

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

2 mois ago

Solved

Remove any row in which a NaN appears
Given the matrix A, return B in which all the rows that have one or more <http://www.mathworks.com/help/techdoc/ref/nan.html NaN...

2 mois ago

Solved

Finding Perfect Squares
Given a vector of numbers, return true if one of the numbers is a square of one of the other numbers. Otherwise return false. E...

2 mois ago

Solved

Set the array elements whose value is 13 to 0
Input A either an array or a vector (which can be empty) Output B will be the same size as A . All elements of A equal to 13...

2 mois ago

Solved

How to locate the position of an element in a vector without using the find function
(copy of prob 105 with test for find function) Write a function posX = *locatePos* (x,y) which returns the location o...

2 mois ago

Solved

Determine whether a vector is monotonically increasing
Return true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return f...

2 mois ago

Solved

Determine if input is odd
Given the input n, return true if n is odd or false if n is even.

3 mois ago

Solved

Back and Forth Rows
Given a number n, create an n-by-n matrix in which the integers from 1 to n^2 wind back and forth along the rows as shown in the...

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

3 mois ago

Solved

Return the 3n+1 sequence for n
A Collatz sequence is the sequence where, for a given number n, the next number in the sequence is either n/2 if the number is e...

3 mois 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 + ...

3 mois ago

Solved

Bullseye Matrix
Given n (always odd), return output a that has concentric rings of the numbers 1 through (n+1)/2 around the center point. Exampl...

3 mois ago

Solved

Fibonacci sequence
Calculate the nth Fibonacci number. Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ... Examples: Inpu...

3 mois ago

Solved

Get the elements of diagonal and antidiagonal for any m-by-n matrix (★★★★)
(copy of prob. 859) In this problem you must submit a solution which returns the diagonal and anti-diagonal elements without ...

4 mois ago

Solved

Column Removal (★★★)
(copy of prob 7) Remove the nth column from input matrix A and return the resulting matrix in output B. So if A = [1 2...

4 mois ago

Solved

Replicate elements in vectors (★★★)
(copy of Prob 867) Replicate each element of a row vector (with NaN) a constant number of times. Examples n=2, A=[1 2...

4 mois ago

Solved

Magnitude of a vector (★★★)
Given a vector x with values [ x1, x2, x3, ..., xn ], compute the magnitude (or length) of the vector which is given by <<htt...

4 mois ago

Solved

Sum of elements of a vector (★★★)
Given any vector x = [x1, x2, x3, ... xn], compute the sum of its elements. Thus, if x = [ 1 3 -2 5 ], then the sum of its el...

4 mois ago

Solved

Sum of terms in a series 1 (★★★)
Given x and n, compute the following sum: |x|+|x|^(1/2)+|x|^(1/3)+|x|^(1/4)+|x|^(1/5) ... + |x|^(1/n) where ||x|| indica...

4 mois ago

Solved

Factorize uniquely! (★★)

4 mois ago

Solved

Vector of digits (★★)
Given a positive integer x, construct a vector y with all the digits of x in the order of appearance in x. Thus, if x = 172...

4 mois ago

Solved

Prime number check (★★)
One way to see if a number x is prime is to compute the remainders obtained when dividing x by all integers from 2 to √(x). If x...

4 mois ago

Solved

Variance computation (★)
Given a vector x with several values, compute the variance, whose formula is given by: <<https://i.imgur.com/Wg95KBE.gif>> ...

4 mois ago