Question: A run is a sequence of adjacent repeated values. Write a Go program that generates a sequence of 2 0 random die tosses in an

A run is a sequence of adjacent repeated values.
Write a Go program that generates a sequence of 20 random die tosses in an array/slice and that prints the die values, marking the runs by including them in parentheses, like this:
12(55)31243(2222)36(55)631
Hint: look into the Go math/rand package for functions to help complete this exercise.
You can use the following pseudocode:
inRun = false
For each valid index i in the array
If inRun
If values[i] is different from the preceding value
Print ).
inRun = false
If not inRun
If values[i] is the same as the following value
Print (.
inRun = true
Print values[i].
If inRun, print ). Write in GO be sure to test before submitting

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!