The test suite of this problem has been updated to actually check for numbers in the specified range (between 3 to 15), so your random solutions should now work.
Any chance you could make the test suite see if the numbers are actually random? :-)
It's actually quite a difficult thing to do well. See for example Problem 44393 at https://www.mathworks.com/matlabcentral/cody/problems/44393 , which so far has only one solver (in addition to my reference solution). Cf. the Test Suites in Problem 174 by Bryant Tran and Problem 44277 by Amitava Biswas. —DIV
(Here it's a little easier because the author can repeatedly call the user's function with the same input, and check for variation in the returned output.)
David, that's kind of what I meant by checking to see if the output was random. Run the code maybe 10-15 times, and see if the values are different each time would be "random enough" for Cody.
If the test suite did check for the values being random, then this solution wouldn't have worked.
Should not the output be random?
https://xkcd.com/221/ is another random number generator along these lines. But seriously, yes, the output should be random. The test suite is busted.
Getting the indices from a vector
Return 'on' or 'off'
Close MATLAB with keyboard
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