Cody

# Problem 42761. Fill the matrix - 1

Solution 2634469

Submitted on 30 Jun 2020 by Rafael S.T. Vieira
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
x = [1:8]'; n = 4; y_correct = [ 0 0 0 0 1 1 0 0 0 2 3 1 0 0 3 7 3 1 0 4 15 7 3 1 5 31 15 7 3 6 62 31 15 7 7 122 62 31 15 8 ]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

y = 0 0 0 0 1 1 0 0 0 2 3 1 0 0 3 7 3 1 0 4 15 7 3 1 5 31 15 7 3 6 62 31 15 7 7 122 62 31 15 8

2   Pass
x = [1.584;-1.015;8.4587;6.0147;9.0258;-10.4785]; n = 4; y_correct = [ 0 0 0 0 1.584 1.584 0 0 0 -1.015 0.569 1.584 0 0 8.4587 10.6117 0.569 1.584 0 6.0147 18.7794 10.6117 0.569 1.584 9.0258 40.5699 18.7794 10.6117 0.569 -10.4785 ]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

y = 0 0 0 0 1.5840 1.5840 0 0 0 -1.0150 0.5690 1.5840 0 0 8.4587 10.6117 0.5690 1.5840 0 6.0147 18.7794 10.6117 0.5690 1.5840 9.0258 40.5699 18.7794 10.6117 0.5690 -10.4785

3   Pass
x = [-2:10]'; n = 3; y_correct = [ 0 0 0 -2 -2 0 0 -1 -3 -2 0 0 -5 -3 -2 1 -9 -5 -3 2 -15 -9 -5 3 -26 -15 -9 4 -46 -26 -15 5 -82 -46 -26 6 -148 -82 -46 7 -269 -148 -82 8 -491 -269 -148 9 -899 -491 -269 10 ]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

y = 0 0 0 -2 -2 0 0 -1 -3 -2 0 0 -5 -3 -2 1 -9 -5 -3 2 -15 -9 -5 3 -26 -15 -9 4 -46 -26 -15 5 -82 -46 -26 6 -148 -82 -46 7 -269 -148 -82 8 -491 -269 -148 9 -899 -491 -269 10

4   Pass
x = [-2:10]'; n = 0; y_correct = x; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

y = -2 -1 0 1 2 3 4 5 6 7 8 9 10

5   Pass
x = [0.814723686393179;0.905791937075619;0.126986816293506;0.913375856139019;0.632359246225410;0.0975404049994095;0.278498218867048;0.546881519204984;0.957506835434298;0.964888535199277]; n = 8; y_correct = [0 0 0 0 0 0 0 0 0.814723686393179;0.814723686393179 0 0 0 0 0 0 0 0.905791937075619;1.72051562346880 0.814723686393179 0 0 0 0 0 0 0.126986816293506;2.66222612615548 1.72051562346880 0.814723686393179 0 0 0 0 0 0.913375856139019;6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0 0 0 0.632359246225410;11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0 0 0.0975404049994095;23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0 0.278498218867048;46.8739840290130 23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0 0.546881519204984;94.0163513583640 46.8739840290130 23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.814723686393179 0.957506835434298;188.443328032957 94.0163513583640 46.8739840290130 23.3465131075727 11.9406659743994 6.11084129215648 2.66222612615548 1.72051562346880 0.964888535199277]; y = fillMatrix(x,n) assert(all(abs(y(:)-y_correct(:))<1e-4));

y = 0 0 0 0 0 0 0 0 0.8147 0.8147 0 0 0 0 0 0 0 0.9058 1.7205 0.8147 0 0 0 0 0 0 0.1270 2.6622 1.7205 0.8147 0 0 0 0 0 0.9134 6.1108 2.6622 1.7205 0.8147 0 0 0 0 0.6324 11.9407 6.1108 2.6622 1.7205 0.8147 0 0 0 0.0975 23.3465 11.9407 6.1108 2.6622 1.7205 0.8147 0 0 0.2785 46.8740 23.3465 11.9407 6.1108 2.6622 1.7205 0.8147 0 0.5469 94.0164 46.8740 23.3465 11.9407 6.1108 2.6622 1.7205 0.8147 0.9575 188.4433 94.0164 46.8740 23.3465 11.9407 6.1108 2.6622 1.7205 0.9649