A run is a sequence of adjacent repeated values. Write a program that generates
ID: 3624511 • Letter: A
Question
A run is a sequence of adjacent repeated values. Write a program that generates a sequence of random die tosses and that prints the die values, marking the runs by including them in parentheses, like this:1 2 (5 5) 3 1 2 4 3 (2 2 2 2) 3 6 (5 5) 6 3 1
Use the following pseudocode:
Set a boolean variable in_run to false
For each valid index i in the vector
{
If in_run
{
If values[i] is different from the preceding value
{
Print )
in_run = false
}
}
Else
{
If values[i] is the same as the following value
{
Print (
in_run = true
}
}
Print values[i]
}
If in_run, print )
Explanation / Answer
http://pastebin.com/DjBwX8PV This only addresses the problem as an array. I'm not too clear on arrays and the time was running out.