Cody

Problem 42775. Raise a polynomial to a power

Solution 1676058

Submitted on 18 Nov 2018
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
p=[2]; N=8; y_correct=256; assert(isequal(polypow(p,N),y_correct))

q = 4 q = 16 q = 256 q = 65536 q = 4.2950e+09 q = 1.8447e+19 q = 3.4028e+38

Assertion failed.

2   Pass
p=[1 1]; N=1; y_correct=[1 1]; assert(isequal(polypow(p,N),y_correct))

3   Fail
p=[1 1]; N=5; y_correct=[1 5 10 10 5 1]; assert(isequal(polypow(p,N),y_correct))

q = 1 2 1 q = 1 4 6 4 1 q = 1 8 28 56 70 56 28 8 1 q = Columns 1 through 14 1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368 1820 560 Columns 15 through 17 120 16 1

Assertion failed.

4   Fail
p=1:5; N=3; y_correct=[1 6 21 56 126 234 369 504 594 574 465 300 125]; assert(isequal(polypow(p,N),y_correct))

q = 1 4 10 20 35 44 46 40 25 q = Columns 1 through 14 1 8 36 120 330 768 1544 2728 4275 5920 7256 7848 7386 5880 Columns 15 through 17 3900 2000 625

Assertion failed.

5   Fail
p=5:-1:1; N=3; y_correct=[125 300 465 574 594 504 369 234 126 56 21 6 1]; assert(isequal(polypow(p,N),y_correct))

q = 25 40 46 44 35 20 10 4 1 q = Columns 1 through 14 625 2000 3900 5880 7386 7848 7256 5920 4275 2728 1544 768 330 120 Columns 15 through 17 36 8 1

Assertion failed.

6   Pass
p=5:-1:1; N=1; y_correct=[5 4 3 2 1]; assert(isequal(polypow(p,N),y_correct))