Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('sortMonomials.m');
assert(~contains(filetext,'regexp'))
|
2 | Pass |
unsortedCoeffs = [-10 7 -10 -7 6 6 3 1 -7 2]';
unsortedExponents = [5 4 2; 2 5 3; 2 1 5; 1 5 4; 1 4 3; 1 3 3; 1 2 1; 0 4 1; 0 2 1; 0 0 5];
[sortedCoeffs,sortedExponents] = sortMonomials(unsortedCoeffs,unsortedExponents);
sortOrder = [1 2 4 3 5 6 8 10 7 9];
assert(isequal(sortedCoeffs,unsortedCoeffs(sortOrder)))
assert(isequal(sortedExponents,unsortedExponents(sortOrder,:)))
|
3 | Pass |
x = randi(1000); y = randi(1000);
[coeffs,exponents] = sortMonomials(x,y);
assert(isequal([x y],[coeffs exponents]))
|
4 | Pass |
unsortedCoeffs = randi(1000,[4 1]);
ough = ['hguot '; 'hguoc '; 'hguolp'; 'hguod '];
unsortedExponents = ough - repmat(randi(100),size(ough));
unsortedExponents = [unsortedExponents -sum(unsortedExponents,2)];
[sortedCoeffs,~] = sortMonomials(unsortedCoeffs,unsortedExponents);
[~,ia] = sort(ough(:,5));
assert(isequal(sortedCoeffs,flipud(unsortedCoeffs(ia))))
|
5 | Pass |
z = [1 3 5+randi(10)];
v1 = perms(z);
v2 = perms(z+[1 0 0]);
v = [v2; v1];
unsortedCoeffs = randi(1000,[size(v,1) 1]);
unsortedExponents = v(randperm(size(v,1)),:);
[sortedCoeffs,sortedExponents] = sortMonomials(unsortedCoeffs,unsortedExponents);
assert(isequal(sortedExponents,v))
|
3117 Solvers
701 Solvers
Getting the indices from a vector
3212 Solvers
858 Solvers
Return a list sorted by number of consecutive occurrences
173 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!