Cody

# Problem 1441. Convolution Power

Solution 234191

Submitted on 23 Apr 2013 by Muthu Annamalai
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, log in.

### Test Suite

Test Status Code Input and Output
1   Pass
%% user_solution = fileread('convpower.m'); assert(isempty(strfind(user_solution,'regexp'))); assert(isempty(strfind(user_solution,'2str'))); assert(isempty(strfind(user_solution,'str2'))); assert(isempty(strfind(user_solution,'interp')));

``` ```

2   Pass
%% x = [1 2 3]; n = 0; y_correct = 1; assert(isequal(convpower(x,n),y_correct))

``` ans = 1 ```

3   Pass
%% x = [3 8 1 2 3]; n = 1; y_correct = [3 8 1 2 3]; assert(isequal(convpower(x,n),y_correct))

``` ans = 1 ans = 3 8 1 2 3 ```

4   Pass
%% x = [3 8 1 2 3]; n = 3; y_correct = [27 216 603 710 570 876 763 354 390 260 63 54 27]; assert(isequal(convpower(x,n),y_correct))

``` ans = 1 ans = 3 8 1 2 3 ans = 9 48 70 28 51 52 10 12 9 ans = 27 216 603 710 570 876 763 354 390 260 63 54 27 ```

5   Pass
%% x = [1 3 2]; n = 2; y_correct = [ 1 6 13 12 4]; assert(isequal(convpower(x,n),y_correct))

``` ans = 1 ans = 1 3 2 ans = 1 6 13 12 4 ```

6   Pass
%% x = [1 1]; n = 10; y_correct = [ 1 10 45 120 210 252 210 120 45 10 1] assert(isequal(convpower(x,n),y_correct))

``` y_correct = 1 10 45 120 210 252 210 120 45 10 1 ans = 1 ans = 1 1 ans = 1 2 1 ans = 1 3 3 1 ans = 1 4 6 4 1 ans = 1 5 10 10 5 1 ans = 1 6 15 20 15 6 1 ans = 1 7 21 35 35 21 7 1 ans = 1 8 28 56 70 56 28 8 1 ans = 1 9 36 84 126 126 84 36 9 1 ans = 1 10 45 120 210 252 210 120 45 10 1 ```

7   Pass
%% x = [1 5 2]; n = 7; y_correct = [1 35 539 4795 27209 102725 261905 451225 523810 410900 217672 76720 17248 2240 128] assert(isequal(convpower(x,n),y_correct))

``` y_correct = Columns 1 through 8 1 35 539 4795 27209 102725 261905 451225 Columns 9 through 15 523810 410900 217672 76720 17248 2240 128 ans = 1 ans = 1 5 2 ans = 1 10 29 20 4 ans = 1 15 81 185 162 60 8 ans = Columns 1 through 8 1 20 158 620 1249 1240 632 160 Column 9 16 ans = Columns 1 through 8 1 25 260 1450 4665 8725 9330 5800 Columns 9 through 11 2080 400 32 ans = Columns 1 through 8 1 30 387 2800 12435 34950 62285 69900 Columns 9 through 13 49740 22400 6192 960 64 ans = Columns 1 through 8 1 35 539 4795 27209 102725 261905 451225 Columns 9 through 15 523810 410900 217672 76720 17248 2240 128 ```