main.swift442 chars18 lines
Explanation:
We start by creating an empty array to store the results of the die rolls.
We then use a loop to roll the die 20 times and append the result to the array.
Next, we loop through the array and print each roll. If the current roll is the same as the previous roll, we add parentheses around it.
The terminator
parameter is used to specify what should be printed after each roll. By default it is a new line, but we set it to a space so the printed rolls are separated by spaces instead.
gistlibby LogSnag