This is a basic MATLAB operation. It is for instructional purposes.
---
If you want to get a random permutation of integers randperm will help.
Given n, put the integers [1 2 3... N] in a random order.
Yes, the test suite is not conclusive, but it is pretty close!
Surely these ! echo "function assert(~) " >./assert.m solutions are not valid?
This solution seems to run correctly in MATLAB (desktop)... can anyone tell me why it is coming back with an "Assertion Failed"?
function vec = makeRandomOrdering(n)
vec = zeros(1, numel(n));
flags = zeros(1, numel(n));
index = 1;
while (sum(flags) ~= numel(n))
pos = randi(numel(n));
if (flags(pos) ~= 1)
vec(index) = n(pos);
index = index + 1;
flags(pos) = 1;
end
end
end
Increment a number, given its digits
506 Solvers
178 Solvers
convert matrix to single column
217 Solvers
Is this triangle right-angled?
1921 Solvers
Given a square and a circle, please decide whether the square covers more area.
146 Solvers