31.1k views
2 votes
Simon says ACTIVITY "Simon Says' is a memory game where "Simon' outputs a sequence of 10 characters (R. G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings. For each match, add one point to user score Upon a mismatch, end the game Sample output with inputs: RRGBRYYBGY "RRGBBRYBGY User score: 4 1 user score

User Cogslave
by
7.7k points

1 Answer

3 votes

Final Answer:

The user score is 4 in the "Simon Says" activity, as there are four matching characters before the first mismatch. The loop adds one point for each match until a mismatch is encountered.

Step-by-step explanation:

In the given "Simon Says" activity, the user's input sequence is "RRGBBRYBGY," and the original sequence provided by Simon is "RRGBRYYBGY." Comparing the two sequences:

The first two characters match ("RR").

The next two characters don't match ("GB" vs. "GBB"), so the game ends.

The user's score is determined by the number of matching characters in the sequence before the mismatch. In this case, there are four matching characters ("RRGB"), resulting in a user score of 4.

User Lithiumhead
by
7.8k points