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 |
n = 6;
y = goldbach3(n);
y_correct = [2,2,2];
assert(isequal(y,y_correct))
|
2 | Pass |
n = 7;
y = goldbach3(n);
y_correct = [2,2,3];
assert(isequal(y,y_correct))
|
3 | Pass |
n = 8;
y = goldbach3(n);
y_correct = [2,3,3];
assert(isequal(y,y_correct))
|
4 | Pass |
n = 9;
y = goldbach3(n);
y_correct1 = [2,2,5];
y_correct2 = [3,3,3];
assert(isequal(y,y_correct1)|isequal(y,y_correct2))
|
5 | Pass |
n = 10;
y = goldbach3(n);
y_correct = [2,3,5];
assert(isequal(y,y_correct))
|
6 | Pass |
n = 11;
y = goldbach3(n);
y_correct1 = [2,2,7];
y_correct2 = [3,3,5];
assert(isequal(y,y_correct1)|isequal(y,y_correct2))
|
7 | Pass |
n = 12;
y = goldbach3(n);
y_correct1 = [2,3,7];
y_correct2 = [2,5,5];
assert(isequal(y,y_correct1)|isequal(y,y_correct2))
|
8 | Pass |
n = 13;
y = goldbach3(n);
y_correct1 = [3,3,7];
y_correct2 = [3,5,5];
assert(isequal(y,y_correct1)|isequal(y,y_correct2))
|
9 | Pass |
n = 14;
y = goldbach3(n);
y_correct = [2,5,7];
assert(isequal(y,y_correct))
|
10 | Pass |
n = 15;
y = goldbach3(n);
y_correct1 = [2,2,11];
y_correct2 = [3,5,7];
y_correct3 = [5,5,5];
assert(isequal(y,y_correct1)|isequal(y,y_correct2)|isequal(y,y_correct3))
|
11 | Pass |
n = 101;
y = goldbach3(n);
assert(isequal(y,sort(y)))
assert(all(isprime(y)))
assert(sum(y)==n)
|
12 | Pass |
n = 102;
y = goldbach3(n);
assert(isequal(y,sort(y)))
assert(all(isprime(y)))
assert(sum(y)==n)
|
13 | Pass |
for n = 250:300
y = goldbach3(n);
assert(isequal(y,sort(y)));
assert(all(isprime(y)));
assert(sum(y)==n);
end
|
14 | Pass |
n = randi(2000)+5; % generate a random integer greater than 5 and smaller than 2006
y = goldbach3(n);
assert(isequal(y,sort(y)))
assert(all(isprime(y)))
assert(sum(y)==n)
|
15 | Pass |
valid = zeros(1,50);
for k = 1:50
n = randi(1000)+5; % generate a random integer greater than 5 and smaller than 1006
yk = goldbach3(n);
valid(k) = (isequal(yk,sort(yk)) & all(isprime(yk)) & sum(yk)==n);
end
assert(all(valid));
|
Sort a list of complex numbers based on far they are from the origin.
4327 Solvers
1421 Solvers
Fix the last element of a cell array
344 Solvers
123 Solvers
234 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!