Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Roll 5 dice. If all 5 match, you won. If not, keep the dice for which there is the highest count and set them aside.

Roll 5 dice. If all 5 match, you won. If not, keep the dice for which there is the highest count and set them aside. (If there's a tie, it doesn't matter which to keep, so let's use the convention of always choosing the smallest number.)
Example 1: Roll 2,5,5,4,5. We have three 5's and only one of the others, so we keep the 5's.
Example 2: Roll 2,5,2,5,1. We have two 2's and two 5's. Since there is a tie between 2 and 5 we use the convention of keeping the smallest which is the 2's.
Example 3: Roll 6,1,3,2,4. We have one of each. Since there is a five-way tie between 1,2,3,4, and 6, we use the convention of keeping the smallest which is the 1.
Then, whichever dice are not kept are rolled again. Again, if all 5 match, you won. If not, keep the dice for which there is the highest count and set them aside. Then, reroll a third and final time. If all 5 match, you won. (On each step, follow the same tie-breaking rule as mentioned previously.)
Example: First roll was 2,5,2,5,1. We kept 2's, and rerolled the two 5's and the 1. Second roll was 2,3,2,3,3. Now we would keep 3's, since there are more of them. Final roll is 6,3,1,3,3.(Highest-count number can change!)
If all 5 dice match, display something fun to the Command window using disp().
Create a function called yahtzeefull that takes an input a 113 row vector randnos and outputs nummatch which is the largest number of matching dice after 3 rolls. The first 5 elements of randnos are your first roll. Every time a die needs to be rerolled, use the next number in the vector. It is possible that not all elements of randnos are used. You can then test your code by calling the function yahtzeefull (randi (6,13,1).
Roll 5 dice. If all 5 match, you won. If not, keep the dice for which there is the highest count and set them aside. (If there's a tie, it doesn't matter which to keep, so let's use the convention of always choosing the smallest number.)
Example 1: Roll 2,5,5,4,5. We have three 5's and only one of the others, so we keep the 5's.
Example 2: Roll 2,5,2,5,1. We have two 2's and two 5's. Since there is a tie between 2 and 5 we use the convention of keeping the smallest which is the 2's.
Example 3: Roll 6,1,3,2,4. We have one of each. Since there is a five-way tie between 1,2,3,4, and 6, we use the convention of keeping the smallest which is the 1.
Then, whichever dice are not kept are rolled again. Again, if all 5 match, you won. If not, keep the dice for which there is the highest count and set them aside. Then, reroll a third and final time. If all 5 match, you won. (On each step, follow the same tie-breaking rule as mentioned previously.)
Example: First roll was 2,5,2,5,1. We kept 2's, and rerolled the two 5's and the 1. Second roll was 2,3,2,3,3. Now we would keep 3's, since there are more of them. Final roll is 6,3,1,3,3.(Highest-count number can change!)
If all 5 dice match, display something fun to the Command window using disp().
Create a function called yahtzeefull that takes an input a 113 row vector randnos and outputs nummatch which is the largest number of matching dice after 3 rolls. The first 5 elements of randnos are your first roll. Every time a die needs to be rerolled, use the next number in the vector. It is possible that not all elements of randnos are used. You can then test your code by calling the function yahtzeefull ).
Example 1: randnos =[4364615423161]
The first roll is 4,3,6,4,6. We have a tie with 4's and 6's. By convention, we keep the 4's and reroll the second, third, and fifth dice. The next 3 elements of randnos are 1,5,4 so those fill in the previous spots giving us 4,1,5,4,4. We again keep the 4's and reroll the second and third dice. The next 2 elements of randnos are 2,3 so those fill in the previous spots giving us 4,2,3,4,4. After all three rolls the largest number of matching dice is 3, because there are 34's. Thus the output nummatch is 3. Note that the elements of randnos at the end 1,6,1 are unused, that's fine.
Example 2: randnos =[3651111412215]
The first roll is 3,6,5,1,. We keep the 1's and reroll the first, second and third dice. The next 3 elements of randnos are 1,1,4 so those fill in the previous spots giving us 1,1,4,1,1. We keep the 1's and reroll the third die. The next element of randnos is 1. That gives us a final roll of 1,1,1,1,1. The output nummatch is 5 and some text should be displayed indicating that a yahtzee was achieved.
The Matlab documentation for ) should be use
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

3. Outline the four major approaches to informative speeches

Answered: 1 week ago

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago