Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('mPoly.m');
assert(~contains(filetext,'regexp'))
|
2 | Pass |
c1 = randi(1000); c2 = randi(1000);
e = 0;
p1 = mPoly(e,c1);
p2 = mPoly(e,c2);
p = p1*p2;
assert(isequal(c1*c2,p.coefficients))
assert(isequal(e,p.exponents))
|
3 | Pass |
e1 = [2 0; 0 1];
c1 = [-1; 1];
e2 = [1 0; 0 0];
c2 = [1; -2];
p1 = mPoly(e1,c1);
p2 = mPoly(e2,c2);
p = p1*p2;
[e,idx] = unique(p.exponents,'rows');
c = p.coefficients(idx);
assert(isequal(e,[0 1; 1 1; 2 0; 3 0]))
assert(isequal(c,[-2; 1; 2; -1]))
|
4 | Pass |
e1 = [0 1 0; 2 0 0];
c1 = [1; -1];
e2 = [0 0 1; 0 0 0];
c2 = [1; -2];
p1 = mPoly(e1,c1);
p2 = mPoly(e2,c2);
p = p1*p2;
[e,idx] = unique(p.exponents,'rows');
c = p.coefficients(idx);
assert(isequal(e,[0 1 0; 0 1 1; 2 0 0; 2 0 1]))
assert(isequal(c,[-2; 1; 2; -1]))
|
5 | Pass |
e1 = [0 0 1; 3 0 0];
c1 = [1; -1];
e2 = [2 0 0; 0 2 0; 0 0 2; 0 0 0];
c2 = [1; 1; 1; -1];
p1 = mPoly(e1,c1);
p2 = mPoly(e2,c2);
p = p1*p2;
[e,idx] = unique(p.exponents,'rows');
c = p.coefficients(idx);
assert(isequal(e,[0 0 1; 0 0 3; 0 2 1; 2 0 1; 3 0 0; 3 0 2; 3 2 0; 5 0 0]))
assert(isequal(c,[-1 1 1 1 1 -1 -1 -1]'))
|
6 | Pass |
c1 = randi(1000,[2 1]);
e1 = randi(1000,[2 2]);
c2 = randi(1000,[3 1]);
e2 = randi(1000,[3 2]);
p1 = mPoly(e1,c1);
p2 = mPoly(e2,c2);
p12 = p1*p2;
p21 = p2*p1;
[e12,i12] = unique(p12.exponents,'rows');
[e21,i21] = unique(p21.exponents,'rows');
c12 = p12.coefficients(i12);
c21 = p21.coefficients(i21);
assert(isequal(e12,e21))
assert(isequal(c12,c21))
|
Select every other element of a vector
16221 Solvers
Find the two most distant points
1233 Solvers
2278 Solvers
Project Euler: Problem 3, Largest prime factor
167 Solvers
208 Solvers