Cody

Problem 641. Make a random, non-repeating vector.

Solution 2048936

Submitted on 6 Dec 2019 by Martin Thomas
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 10; flagSame = isequal(makeRandomOrdering(n), makeRandomOrdering(n)); flagAllUsed = isequal([1:n],sort(makeRandomOrdering(n))); assert(~flagSame & flagAllUsed)

N = 1 2 3 4 5 6 7 8 9 10 ans = 5 8 2 10 6 3 1 9 4 7 N = 1 2 3 4 5 6 7 8 9 10 ans = 7 4 2 3 5 9 6 8 10 1 N = 1 2 3 4 5 6 7 8 9 10 ans = 7 6 1 2 10 4 5 8 3 9

Suggested Problems

More from this Author52

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!