Given n (always odd), return output a that has concentric rings of the numbers 1 through (n+1)/2 around the center point. Examples:
Input n = 3 Output a is [ 2 2 2 2 1 2 2 2 2 ]
Input n = 5 Output a is [ 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 3 3 ]
The image processing toolbox is not available!
A fantastic 1... calculate based on d distance of each element 4m central 1...
I see that now Jan, this stinks!
Nice Problem!
I have a question about why I can't use bwdist to generate the chessboard matrix?
Image Processing ToolBox is not allowed?
Fun problem!
Interesting problem
good problem. What is use of this matrix?
Like this one!!
Had lots of fun figuring it out
Hi guys,
Any one know how can you view a solution with lesser size than the one you submitted ?
Interesting one
never have the chance to see how people did it with less than 10 size
Solving another cody problem you will enable you to see all the solutions to a this problem, and so learning can take place :)
why does my solution work on matlab and not here?
Very challenging problem
Best problem out of those I solved till now.
I have tried using padarray. Its working totally fine with my MATLAB R2017b, but this shows undefined function. Why? Which version cody compiler is compatible with?
Simple Problem, but work out a lot for it, in the end I find the solution too simple. But great thing is I've learned a lot from it.
wow
Nice problem. I like such matrix problems.
Nice One
Love it!!
A lot easier than I originally anticipated. Once you start setting up the problem variables, it comes together pretty easily.
nic problem..it was fun
function a = bullseye(n)
a = 1;
for i = 2:(n+1)/2
a = padarray(a, [1,1], i, 'both');
end
end
Why doesn't this function work?
Wow, this wasn't easy for me
clever!
Should be the best for now!
nice! didn't know about discretize til i saw this solution
This is the actual, sans regexp, size of the leading solution: 25
The ans is amazing.Contrast to my last solution,the size add 2.
This solution is from online froum.
my solution clearly works on my matlab. not here. wonder why
Shame you can't use padarray.
it's very nice solution, but sadly it's not general solution
My original objective was to reduce the Cody size as much as possible. You can make this solution general by using y = discretize(spiral(n), [0 1:2:n].^2+.5) or y = discretize(spiral(n), [0 1:2:n].^2, 'IncludedEdge','right'), which has a higher size though.
more elegant solution than a loop: Use the LDL decomposition on the bullseye matrix and you will find an interesting L and D matrix. THe D matrix is diagonale and can be built using n only. THe matrix L is the sum of a lower triangular matrix whose lowest part is put to zero using the mirrored triangular matrix. Finally the identity matrix is added :)
no image processing toolbox then?
:P yeah, I know...
hahahah
funny code!
Not exactly a general solution...
Tester -*-
This would work if it recognized 'padarray'. Is cody using an older or more spartan version of matlab?
Solutions like this are tricky. It would be nice if we could all agree as a community that this is not a valid way to reduce the size of a solution.
Not fair :(
wow
All your base are belong to us
427 Solvers
Reverse the Words (not letters) of a String
250 Solvers
Generate N equally spaced intervals between -L and L
448 Solvers
155 Solvers
312 Solvers