Given n, odd number > 1, return n by n matrix consist of "null" and "*" characters arranged like a diamond.
No toolbox functions please.
n = 3
m =
* * * *
n = 7
m =
* * * * * * * * * * * *
may I suggest reinforcing your test suite using isequal or strcmp to hardcoded diamond strings?
updated!
why is the first test showing error while others passing :
assert(all(find(double(make_diamond(3)) == 0) == [1 3 5 7 9]') == 1)
Matrix dimensions must agree. Error in Test1 (line 4) assert(all(find(double(make_diamond(3)) == 0) == [1 3 5 7 9]') == 1)
what is this supposed to mean? Am I missing something?
Extract leading non-zero digit
967 Solvers
Project Euler: Problem 2, Sum of even Fibonacci
461 Solvers
Calculate the Hamming distance between two strings
144 Solvers
Cell Counting: How Many Draws?
254 Solvers
165 Solvers