There are 500 cards within the game in total. Each card is numbered from 1 to 250 and each number appears twice in the whole set of cards.
The player’s 100 cards are always stored in numerical order.
When a player has a valid run of five cards within their 100 cards they have won the game.
A valid run:
• consists of five cards
• can start from any position in the player’s 100 cards
• the second card’s value is one more than the first card’s value, the third card’s value is one more than the second card’s value, the fourth card’s value is one more than the third card’s value, and the fifth card’s value is one more than the fourth card’s value.
Below are examples of valid runs which means a player has won.
Valid run example 1
Valid run example 2
Below are examples of invalid runs.
Invalid run example 1
Invalid run example 2
Invalid run example 3
Write a C# program to check if a player has a valid run of five cards within their 100 cards.
When writing your program you should assume:
• there is an array called cards that contains the values of the player’s 100 cards
• cards[0] will contain the value of the first card and cards[99] will contain the value of the last card
• the values in cards are already stored in numerical order
• there is a Boolean variable called gameWon that has a value of False.
Your program should set gameWon to True if there is a valid run.
You should use meaningful variable name(s) and C# syntax in your answer.
The answer grid below contains vertical lines to help you indent your code.