This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
assert(isequal(foldl(@plus, 0, 1:100), 5050));
|
2 | Pass |
r = rand(1, 100);
y = foldl(@plus, 0, r);
yc = sum(r);
assert(abs(y - yc)/abs(y) < 1e-6);
|
3 | Pass |
assert(isequal(foldl(@times, 1, 1:15), factorial(15)));
|
4 | Pass |
r = rand(1, 1000);
assert(isequal(foldl(@max, -Inf, r), max(r)));
|
5 | Pass |
assert(isequal(foldl(@(x_, y_) 2*x_ + y_, 4, 1:3), 43));
|
6 | Pass |
sumplusfive = foldl(@plus, 5);
assert(isequal(sumplusfive(1:100), 5055));
|
7 | Pass |
concat = foldl(@(x_, y_) [x_ y_]);
r1 = rand(1, 10);
r2 = rand(1, 10);
assert(isequal(concat(r1, r2), [r1 r2]));
|
3074 Solvers
Calculate the area of a triangle between three points
871 Solvers
177 Solvers
Find nearest prime number less than input number
268 Solvers
Determine if input is a perfect number
145 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!