Nearest Numbers
Given a row vector of numbers, find the indices of the two nearest numbers.
Examples:
[index1 index2] = nearestNumbers([2 5 3...
4年弱 前
解決済み
Make a Palindrome Number
Some numbers like 323 are palindromes. Other numbers like 124 are not. But look what happens when we add that number to a revers...
4年弱 前
解決済み
Find the palindrome
Given the string a, find the longest palindromic sub-string b.
So when
a = 'xkayakyy';
you should return
b = 'kayak';
4年弱 前
解決済み
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...
Remove all the words that end with "ain"
Given the string s1, return the string s2 with the target characters removed.
For example, given
s1 = 'the main event'
your ...
Remove all the consonants
Remove all the consonants in the given phrase.
Example:
Input s1 = 'Jack and Jill went up the hill';
Output s2 is 'a ...
4年弱 前
解決済み
Divisible by 7
Pursuant to the <http://www.mathworks.com/matlabcentral/cody/problems/42404-divisible-by-2 first problem> in this series, this o...
4年弱 前
解決済み
Count the primes in Collatz sequences
Several Cody problems (21, 69, 42937, 44448, 44784, 52422) involve Collatz sequences. These start with a seed . If is odd, the ...
4年弱 前
解決済み
Find the peak 3n+1 sequence value
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...
4年弱 前
解決済み
Ugly numbers - 01
Ugly numbers are those whose prime factors are 2, 3 or 5.
find the nth ugly number.
4年弱 前
解決済み
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年弱 前
解決済み
Count consecutive 0's in between values of 1
So you have some vector that contains 1's and 0's, and the goal is to return a vector that gives the number of 0's between each ...
4年弱 前
解決済み
Symmetry of vector
Determine whether the vector is symmetric or not (vector could be even or odd in length).
For example:
x = [1 2 3 3 2 1] is s...
4年弱 前
解決済み
Insert zeros into vector
Insert zeros after each elements in the vector. Number of zeros is specified as the input parameter.
For example:
x = [1 ...
4年弱 前
解決済み
Capitalize
Capitalize the 1st letter of each input. Other letters should be lowercase.
For example -
a='alphaS' >> 'Alphas'
a='1...
4年弱 前
解決済み
Convert from Base 10 to base 5
Convert the input number from base 10 into base 5:
for example:
if a(in base 10)= 5
then a(in base 5)= 10
4年弱 前
解決済み
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...