Cody

Problem 830. Fill a zeros matrix

Solution 2006898

Submitted on 7 Nov 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
value = -13; row = 2; col = 3; B = [0 0 0 0 0 -13]; assert(isequal(your_fcn_name(value,row,col),B)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 6 y = 0.3620 0.6722 0.6924 0.9635 0.5043 -13.0000 y = 0 0 0 0 0 -13 B = 0 0 0 0 0 -13

for forbidden

2   Fail
value = 2012; row = [ 2 3 3 5 ]; col = [ 1 1 4 4 ]; C = [ 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012]; assert(isequal(your_fcn_name(value,row,col),C)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 18 20 y = 1.0e+03 * 0.0009 0.0001 0.0007 0.0003 2.0120 0.0005 0.0006 0.0008 2.0120 0.0002 0.0007 2.0120 0.0001 0.0005 0.0004 0.0008 0.0003 0.0006 0.0006 2.0120 y = 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012 B = 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012

for forbidden

3   Fail
I = [ 2 3 3 5 1 4 9 2 3 9 ]; J = [ 1 1 4 4 5 5 6 8 8 9 ]; assert(isequal(your_fcn_name(0,I,J),zeros(9))) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 30 32 37 40 54 65 66 81 y = 0.9505 0.2924 0.0332 0.2541 0 0.0876 0.9795 0.5360 0.9708 0 0.2989 0.2470 0.8918 0.0251 0.2234 0.2751 0 0.6352 0 0.1407 0.8052 0 0.9155 0.8449 0.5171 0 0.9058 0.2244 0.0038 0.5512 0.4289 0 0.8726 0.8149 0.0933 0.3143 0.4715 0.3138 0.8059 0 0.2776 0.7135 0.4438 0.0347 0.9347 0.0919 0.4389 0.5643 0.3920 0.0211 0.4506 0.7913 0.1836 0.2442 0.8049 0.2097 0.6191 0.0098 0.3375 0.2249 0.4293 0.0822 0.2066 0.8635 0.6374 0.9187 0.2797 0.2017 0.2706 0.5351 0.4165 0.2574 0.6544 0.8584 0.0443 0.5667 0.9099 0 0.3879 0.2154 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

for forbidden

4   Fail
L = [ 2 3 3 5 1 4 9 2 3 9 ]; M = [ 1 1 4 4 5 5 6 8 8 9 ]; sol =[ 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1]; assert(isequal(your_fcn_name(1,L,M),sol)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 30 32 37 40 54 65 66 81 y = 0.3672 0.1404 0.1959 0.6533 1.0000 0.7715 0.6920 0.3029 0.1696 1.0000 0.6348 0.8560 0.1722 0.7636 0.6831 0.2937 1.0000 0.4995 1.0000 0.3216 0.4683 1.0000 0.7826 0.9336 0.4868 1.0000 0.6653 0.1906 0.3927 0.8255 0.2102 1.0000 0.0166 0.5491 0.5812 0.2804 0.0584 0.4271 0.1271 1.0000 0.9626 0.0268 0.3274 0.2628 0.1835 0.3675 0.7090 0.6173 0.1943 0.1343 0.6601 0.4396 0.4822 0.7465 0.0760 0.4030 0.9329 0.1613 0.8919 0.3691 0.6584 0.1569 0.4301 0.2115 0.5231 0.3955 0.1910 0.8280 0.6249 0.4189 0.1304 0.5338 0.6544 0.0092 0.7467 0.7292 0.6158 1.0000 0.5568 0.7902 1.0000 y = 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 B = 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1

for forbidden

5   Fail
I = [ 2 3 3 5 1 4 9 2 3 9 ]; J = [ 1 1 4 4 5 5 6 8 8 9 ]; Z=[ 0 0 0 0 1999 0 0 0 0 1999 0 0 0 0 0 0 1999 0 1999 0 0 1999 0 0 0 1999 0 0 0 0 0 1999 0 0 0 0 0 0 0 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 1999 ]; assert(isequal(your_fcn_name(1999,I,J),Z)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 30 32 37 40 54 65 66 81 y = 1.0e+03 * 0.0000 0.0010 0.0008 0.0007 1.9990 0.0002 0.0002 0.0002 0.0008 1.9990 0.0001 0.0001 0.0002 0.0009 0.0002 0.0009 1.9990 0.0002 1.9990 0.0005 0.0008 1.9990 0.0009 0.0009 0.0000 1.9990 0.0008 0.0005 0.0004 0.0005 0.0001 1.9990 0.0007 0.0002 0.0007 0.0003 0.0000 0.0003 0.0008 1.9990 0.0007 0.0001 0.0004 0.0004 0.0007 0.0009 0.0006 0.0001 0.0001 0.0009 0.0003 0.0002 0.0001 0.0008 0.0004 0.0003 0.0001 0.0006 0.0009 0.0003 0.0005 0.0004 0.0004 0.0007 0.0010 0.0008 0.0003 0.0004 0.0007 0.0001 0.0004 0.0004 0.0006 0.0005 0.0001 0.0004 0.0005 1.9990 0.0004 0.0001 1.9990 y = 0 0 0 0 1999 0 0 0 0 1999 0 0 0 0 0 0 1999 0 1999 0 0 1999 0 0 0 1999 0 0 0 0 0 1999 0 0 0 0 0 0 0 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 1999 B = 0 0 0 0 1999 0 0 0 0 1999 0 0 0 0 0 0 1999 0 1999 0 0 1999 0 0 0 1999 0 0 0 0 0 1999 0 0 0 0 0 0 0 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 1999

for forbidden