Mechanical engineering student. Minoring in 'Applied and computational mathematics. '

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

circa 2 anni ago

Solved

Sum of diagonal of a square matrix

If x = [1 2 4; 3 4 5; 5 6 7] then y should be the sum of the diagonals of the matrix y = 1 + 4 + 7 = 12

circa 2 anni 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

circa 2 anni ago

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

circa 2 anni ago

Solved

Find the nearest prime number

Happy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers. Given a positive in...

circa 2 anni ago

Solved

Add more zeros

Find code that adds one 0 to each sequence of 0 in a string (composed with only 0 or 1). For example: '1010' -> '100100' ...

circa 2 anni ago

Solved

Calculate the Hamming distance between two strings

Inspired by a similar Cody problem found <http://www.mathworks.com/matlabcentral/cody/problems/93-calculate-the-levenshtein-dist...

circa 2 anni ago

Solved

Reverse the Words (not letters) of a String

*Description* Change the words of a string such that the words appear in reverse order. You may assume that the string is a n...

circa 2 anni ago

Solved

letter yes yes & letter no no

Split a string into two strings, wherein the first string has all alphabetic letters and the second string has all the remaining...

circa 2 anni ago

Solved

Simple equation: Annual salary

Given an hourly wage, compute an annual salary by multiplying the wage times 40 and times 50, because salary = wage x 40 hours/w...

circa 2 anni ago

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

circa 2 anni ago

Solved

Return the first and last character of a string

Return the first and last character of a string, concatenated together. If there is only one character in the string, the functi...

circa 2 anni 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 ...

circa 2 anni 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...

circa 2 anni ago

Solved

Flip the main diagonal of a matrix

Given a n x n matrix, M, flip its main diagonal. Example: >> M=magic(5); >> flipDiagonal(M) 9 24 1 ...

circa 2 anni ago

Solved

Permute diagonal and antidiagonal

Permute diagonal and antidiagonal For example [1 2 3;4 5 6;7 8 9] -> [3 2 1;4 5 6;9 8 7] WITHOUT diag function (and variable n...

circa 2 anni ago

Solved

Matrix with different incremental runs

Given a vector of positive integers a = [ 3 2 4 ]; create the matrix where the *i* th column contains the vector *1:a(i)...

circa 2 anni ago

Solved

Set some matrix elements to zero

First get the maximum of each *row*, and afterwards set all the other elements to zero. For example, this matrix: 1 2 3 ...

circa 2 anni 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...

circa 2 anni ago

Solved

Remove NaN ?

input -> matrix (n*m) with at least one element equal to NaN; output -> matrix(p*m), the same matrix where we deleted the enti...

circa 2 anni 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)....

circa 2 anni ago

Solved

Is this is a Tic Tac Toe X Win?

For the game of <https://en.wikipedia.org/wiki/Tic-tac-toe Tic Tac Toe> we will be storing the state of the game in a matrix M. ...

circa 2 anni ago

Solved

Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.

Submit your answer to this problem a multiple of 5 seconds after the hour. Your answer is irrelevant; the only thing that matte...

circa 2 anni ago

Solved

5 Prime Numbers

Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numb...

circa 2 anni ago

Solved

Extra safe primes

Did you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is...

circa 2 anni ago

Solved

Spot the First Occurrence of 5

This problem series invites you to solve two simple problems related to the integer NUMBER FIVE, in order to celebrate <https://...

circa 2 anni ago

Solved

Pentagonal Numbers

Your function will receive a lower and upper bound. It should return all pentagonal numbers within that inclusive range in ascen...

circa 2 anni ago

Solved

Basic electricity in a dry situation

⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ &#...

circa 2 anni ago