Tricky problem !!
At the end, apply sum_array(permute(n)). Or you could use actual random numbers using this same technique, but there maybe repeated values.
well done guillaume, thanks for trying random numbers as well. great effort!
well done alfonso, thanks for trying random numbers as well. im learning new techniques here as well.
well done. alfonso how can i amend the problem so that the coder will be forced to generate random values? :)
true randomness is a bit involved to test (particularly without the stats toolbox), plus the sum constrain adds some additional complexity to the randomness of the resulting values (see for example this Cody problem: http://www.mathworks.com/matlabcentral/cody/problems/331-compute-area-from-fixed-sum-cumulative-probability). In any way, the simplest solution to discourage this sort of extremely-non-random solutions would probably be running your current testsuite twice (with identical inputs) and then checking that the returned vectors are different...
Another possibility, would be to test that there is no repetition in the returned values, which can easily be tested with: assert(all(diff(sort(sum_array))));
you're right guillaume, i apppreciate that.
well done! :) quick solution. however i was expecting coder to generate random values each epoch :)
I've now provided a solution that does generate random values.
i've changed the test suit following ur approach, thanks.
Find relatively common elements in matrix rows
Are you in or are you out?
Back to basics 3 - Temp Directory
Fill a zeros matrix
Check if equal
Flip the right coin to survive!
Simulating the selection of a state with given probabilities
Best Square-Shaped Grid for Subplot
last n digit of a power function
Sum of Dividend Digits
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office