Cody

# Problem 830. Fill a zeros matrix

Solution 1381334

Submitted on 15 Dec 2017 by David Verrelli
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   Pass
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')

sz = 2 3 B = 0 0 0 0 0 -13 B = 0 0 0 0 0 -13

2   Pass
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')

sz = 5 4 B = Columns 1 through 14 0 2012 2012 0 0 0 0 0 0 0 0 0 0 0 Columns 15 through 20 0 0 0 2012 0 2012 B = 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012

3   Pass
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')

sz = 9 9 B = Columns 1 through 29 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 Columns 30 through 58 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 Columns 59 through 81 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

4   Pass
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')

sz = 9 9 B = Columns 1 through 29 0 1 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 Columns 30 through 58 1 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Columns 59 through 81 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 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

5   Pass
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')

sz = 9 9 B = Columns 1 through 14 0 1999 1999 0 0 0 0 0 0 0 0 0 0 0 Columns 15 through 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 29 through 42 0 1999 0 1999 0 0 0 0 1999 0 0 1999 0 0 Columns 43 through 56 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 Columns 57 through 70 0 0 0 0 0 0 0 0 1999 1999 0 0 0 0 Columns 71 through 81 0 0 0 0 0 0 0 0 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