Community Profile

# Douglas Knox

### Space Exploration Technologies

65 total contributions since 2012

View details...

Contributions in
View by

Solved

Quote Doubler
Given a string s1, find all occurrences of the single quote character and replace them with two occurrences of the single quote ...

oltre un anno ago

Solved

Replace NaNs with the number that appears to its left in the row.
Replace NaNs with the number that appears to its left in the row. If there are more than one consecutive NaNs, they should all ...

oltre un anno ago

Solved

Length of the hypotenuse
Given short sides of lengths a and b, calculate the length c of the hypotenuse of the right-angled triangle. <<http://upload....

oltre un anno ago

Solved

Which doors are open?
There are n doors in an alley. Initially they are all shut. You have been tasked to go down the alley n times, and open/shut the...

oltre un anno ago

Solved

Counting Money
Add the numbers given in the cell array of strings. The strings represent amounts of money using this notation: \$99,999.99. E...

oltre un anno 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,...

oltre un anno ago

Solved

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

circa 3 anni ago

Solved

Generate a vector like 1,2,2,3,3,3,4,4,4,4
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] And if n = 5, then return [1 2 2...

circa 3 anni ago

Solved

Lightning strike distance: Writing a function
Write a function named LightningDistance that outputs "distance" given input "seconds". Seconds is the time from seeing lightnin...

circa 5 anni ago

Solved

Circle area using pi
Given a circle's radius, compute the circle's area. Use the built-in mathematical constant pi.

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

circa 6 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 6 anni ago

Solved

Binary numbers
Given a positive, scalar integer n, create a (2^n)-by-n double-precision matrix containing the binary numbers from 0 through 2^n...

circa 6 anni ago

Solved

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

circa 6 anni ago

Solved

Bottles of beer
Given an input number representing the number of bottles of beer on the wall, output how many are left if you take one down and ...

circa 6 anni ago

Solved

Find the alphabetic word product
If the input string s is a word like 'hello', then the output word product p is a number based on the correspondence a=1, b=2, ....

circa 6 anni ago

Solved

Cell joiner
You are given a cell array of strings and a string delimiter. You need to produce one string which is composed of each string fr...

circa 6 anni ago

Solved

Too mean-spirited
Find the mean of each consecutive pair of numbers in the input row vector. For example, x=[1 2 3] ----> y = [1.5 2.5] x=[1...

circa 6 anni ago

Solved

Swap the input arguments
Write a two-input, two-output function that swaps its two input arguments. For example: [q,r] = swap(5,10) returns q = ...

circa 6 anni ago

Solved

Nearest Numbers
Given a row vector of numbers, find the indices of the two nearest numbers. Examples: [index1 index2] = nearestNumbers([2 5 3...

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

circa 6 anni ago

Solved

Which values occur exactly three times?
Return a list of all values (sorted smallest to largest) that appear exactly three times in the input vector x. So if x = [1 2...

circa 6 anni ago

Solved

Reverse the vector
Reverse the vector elements. Example: Input x = [1,2,3,4,5,6,7,8,9] Output y = [9,8,7,6,5,4,3,2,1]

circa 6 anni ago

Solved

Remove the vowels
Remove all the vowels in the given phrase. Example: Input s1 = 'Jack and Jill went up the hill' Output s2 is 'Jck nd Jll wn...

circa 6 anni ago

Solved

Put two time series onto the same time basis
Use interpolation to align two time series onto the same time vector. This is a problem that comes up in <http://www.mathwork...

oltre 6 anni 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...

oltre 6 anni ago

Solved

Distance walked 1D
Suppose you go from position 7 to 10 to 6 to 4. Then you have walked 9 units of distance, since 7 to 10 is 3 units, 10 to 6 is 4...

oltre 6 anni ago

Solved

Elapsed Time
Given two date strings d1 and d2 of the form yyyy/mm/dd HH:MM:SS (assume hours HH is in 24 hour mode), determine how much time, ...

circa 7 anni ago

Solved

Target sorting
Sort the given list of numbers |a| according to how far away each element is from the target value |t|. The result should return...

circa 7 anni ago

Solved

Sum all integers from 1 to 2^n
Given the number x, y must be the summation of all integers from 1 to 2^x. For instance if x=2 then y must be 1+2+3+4=10.

circa 7 anni ago