Cody

# Problem 44707. Raise each element to the power of its index in a matrix

Solution 1662492

Submitted on 30 Oct 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
x = [1,2;3,4]; y_correct = 274; assert(isequal(matrix_pow(x),y_correct))

x = 1 3 2 4 le = 1 2 3 4 y = 1 3 2 4 1 9 4 16 1 27 8 64 1 81 16 256 y = 4 120 30 340

Assertion failed.

2   Fail
x = [1 7 8 -9]; y_correct = 7123; assert(isequal(matrix_pow(x),y_correct))

x = 1 7 8 -9 le = 1 2 3 4 y = 1 7 8 -9 1 49 64 81 1 343 512 -729 1 2401 4096 6561 y = 4 2800 4680 5904

Assertion failed.

3   Fail
x = eye(3).*8; y_correct = 134250504; assert(isequal(matrix_pow(x),y_correct))

x = 8 0 0 0 8 0 0 0 8 le = 1 2 3 4 5 6 7 8 9 y = 8 0 0 0 8 0 0 0 8 64 0 0 0 64 0 0 0 64 512 0 0 0 512 0 0 0 512 4096 0 0 0 4096 0 0 0 4096 32768 0 0 0 32768 0 0 0 32768 262144 0 0 0 262144 0 0 0 262144 2097152 0 0 0 2097152 0 0 0 2097152 16777216 0 0 0 16777216 0 0 0 16777216 134217728 0 0 0 134217728 0 0 0 134217728 y = 153391688 0 0 0 153391688 0 0 0 153391688

Assertion failed.