Christian, I think that this problem is fundamentally okay, except that test problem #1 has an incorrect result, and it is a bit ambiguous about what the result *should* be in the case that the input in a zero matrix. In the latter case, I think you are right, but since the test of similarity only involves the matrix elements that are not zero, and there are none, I suppose there could be some room for disagreement. Certainly, the only possible correct answers would be either the entire matrix or the empty matrix.
Paragraph 3 says "5 can be represented as pp, pxx and pxmm ...", but if I am not mistaken, the value of 'pxmm' is 2. Could you have meant 'pxxm'?
I see. But I guess that doesn't work when you try to run the test in the ScratchPad to check your solution. It just complains that there is no function named modexp().