sorry mate, this is unfair for those who actually came up with a compact solution
No need to be sorry.
Personally I think the regexp should be always forbidden.
I used it (and I had never thought about it before) because it seems that everyone is using it.
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
filetext = fileread('summ.m');
assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')
|
2 | Pass |
v = randi(10, 1, randi(10));
s = summ(v);
assert(length(s) == length(v) - 1)
|
3 | Pass |
v = 1:10;
s_correct = 3:2:19;
assert(isequal(summ(v),s_correct))
|
4 | Pass |
v = [1; 2; 4; 4; 5; 8];
s_correct = [3; 6; 8; 9; 13];
assert(isequal(summ(v),s_correct))
|
204 Solvers
Implement simple rotation cypher
805 Solvers
07 - Common functions and indexing 4
258 Solvers
Rounding off numbers to n decimals
279 Solvers
Find Out sum of principal diagonal element of given matrix
151 Solvers