Problem 44288. Throwing Dice - Will You Be Eaten By The Dragon?
Solution Stats
Problem Comments
-
9 Comments
Hello, Erin. It's a really interesting problem. According to Solution 1539769, I think it would be worthwhile for you to include some (small) tolerances within the assert statements in your Test Suite, to allow for rounding due to computations in 'double precision'. —DIV
I agree with David.
The solution to this problem was stupidly easier than I first thought. Expected value of your own throws is all that really matters here.
The test suite has been updated with additional test cases and a check against a tolerance instead of using isequal()
Is test case 7 generating feasible game conditions?
For example:
x = randi([10 100],1,10) -> generates 10 random numbers between 10 and 100, inclusively, a potential result would be:
x =
85 43 18 92 88 48 35 97 78 100
In test case 7, y=5 (rolling 5 sided die); and if sum of all y-sided dice must equal x (sides of dragon die), then x mod 5 must equal 0, or in general, x mod y = 0. Depending on the nature of the reference solution, this might get overlooked. Simulating test cases allows for the use of an approximation method based on the law of large numbers; however, a simulation would not be possible for conditions requiring fractional dice. As such, I would assume the reference solution is limiting the solution methodology/framework to leveraging probability theory.
Whereas, this still encourages rigorous mathematical reasoning and analysis skills, it discourages the solver from using the power of computational computing to approximate solutions for difficult problems using much simpler mathematical methods, which to me feels like the general purpose behind using MATLAB in the first place.
I am so lost, I need help :(
@AJ work out the probability of survival (as a function of x and y) on paper, and then implement it. You don't need to simplify much on paper BTW, keeping sums etc. is fine.
Can someone clear up this 2 confusions i have about the problem.
The problem says i roll several dice of y sides.How many is that? so i just put a rand 100 or smth to see how many times i'll roll?
And second is since i know my dice have y sides how can the sum of the sides be x since x is random?
@Alex You roll x/y dice, each of which has y sides. Each die is rolled once. x is not random; instead, it's supplied to your function as an argument.
Solution Comments
Show commentsProblem Recent Solvers124
Suggested Problems
-
205 Solvers
-
359 Solvers
-
230 Solvers
-
1192 Solvers
-
7167 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!