MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**Description**

Return two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.

**Example**

[x1,x2] = rollDice(); x1 = 5; x2 = 2;

910 correct solutions
1135 incorrect solutions

Last solution submitted on Nov 24, 2014

5 players like this problem

2 Comments

niko_k
on 27 Aug 2013

solution is correct in my opinion.

Tim
on 27 Aug 2013

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.

1 Comment

Paul Peeling
on 23 Nov 2012

my second ever pseudo random number generator (the first wasn't very random) http://en.wikipedia.org/wiki/Linear_congruential_generator

2 Comments

Peter Wittenberg
on 11 Aug 2012

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.

Matthew M.
on 28 Aug 2012

^Agreed.

1 Comment

Kye Taylor
on 31 Mar 2012

Super rad test suite

1 Comment

Giuseppe Cardillo
on 20 Feb 2012

THIS SOLUTION IS CORRECT!!!!!

1 player likes this solution

1 Comment

Santiago Velasco-Forero
on 2 Aug 2012

False solution.

2 Comments