Return two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.
[x1,x2] = rollDice();
x1 = 5;
x2 = 2;
is the solution correct???
To clarify the problem statement, it would be good to specify the dice are fair.
I've done something like this on an arduino for one of my classes
The first test case for this problem is flat out statistically terrible! In fact, it is quite easy for that assertion to fail on a well defined set of uniform dice! So if you submitted a "valid" solution to this trivial problem, and it failed, then re-submit it. It may well succeed the second time you try, with no change to your function at all.
Use randi function instead of rand.
Rigorous testing of RNG's is a challenging topic. See e.g. https://en.wikipedia.org/wiki/Diehard_tests and https://en.wikipedia.org/wiki/TestU01 .
why can't use unidrnd(6)?
Anyone want to tell me the odds of correctly completing the problem, and then having the checker reject it? Because i have a screenshot of my solution being rejected. Tried exactly the same again and it passed.
@jiangming wang: Cody utilizes vanilla MATLAB (no toolboxes).
Someone please explain me the question
Đề khó hiểu thật !
I offered a solution that should be working (works okay in Matlab) but not here: round(rand()*5+1); - not the most optimum, but still provides the correct output, yet fails the test
can anyone help me why
x1 = 1 + (5)*rand(1,1);
x2 = 1 + (5)*rand(1,1);
This failed on first submission, and completed successfully on second. Does this mean the test is non-robust?
LOL. Just my luck.
solution is correct in my opinion.
rand(1,1)*5+1 will produce random numbers uniformly distributed between 1 and 6; round will convert values from 1 to 1.5 to 1, and values from 1.5 to 2.5 to 2, so 1 will occur only about half as often as 2. Overall, 1 and 6 will occur only about half as often as 2, 3, 4, and 5.
my second ever pseudo random number generator (the first wasn't very random) http://en.wikipedia.org/wiki/Linear_congruential_generator
This is not two random rolls. The second number will never match the first, so the statistical distribution is not correct, although the test suite is not sophisticated enough to catch it.
Super rad test suite
THIS SOLUTION IS CORRECT!!!!!
Not correct. Same coding issue as in Solution 311131.
Agreed: this is not a genuine solution, although it does (sometimes) pass the current test as implemented.
Nice! didn't know about that function.
2 b | ~ 2 b
Solve the set of simultaneous linear equations
04 - Scalar Equations 2
Length of the hypotenuse
Is this triangle right-angled?
The Bomb Problem
Check to see if a Sudoku Puzzle is Solved
THE CALCULATOR OF LOVE
The Dark Side of the Die
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