What sequence means and give me some suggestions

In summary: Just iterate through the cards and check if the current card's value is one less than the next card's value. If it is, continue checking the next two cards. If all five cards have values that are one less than the next card, then return 1. Otherwise, return 0.In summary, the conversation is about creating a function in C that can determine if a set of 5 cards has a sequence of values. The sequence is defined as 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, with ace considered as either before 2 or after king. The function should return 1 if the set of cards has
  • #1
brad sue
281
0
Hi, please can someone help me with this.

I want to write a function sequence in C that returns 1 when a set of 5 cards appear in sequence ; 0 if not.

I don't understand very well what to do here.

the sequence is 2,3,4,5,6,7,8,9,10,jack,queen,king, with ace considered as either before 2 or after king as needed

For example the set of cards( given as follow):

two of diamonds
four of clubs
six of hearts
three of hearts
five of spades

must have sequence =1;


but for the set of cards:

two of spades
king of spades
ace of clubs
three of diamonds
five of hearts

must have sequnce =0


I give this second example since I do not understand why the sequence is 0 here.

Can someone explain me what sequence means and give me some suggestions to write the function called sequence??
Please do not use structure

Thank you for your time.
B
 
Technology news on Phys.org
  • #2
A sequence would be a straight in Poker terminology. Meaning 5 cards whose values are one after the other. The first set is 2, 3, 4, 5, 6, a sequence, so you return 1. The second set is A, 2, 3, 5, K, not a sequence, so you return a 0. What you are returning is a boolean value. A 1 is a boolean value signifying "true", and 0 is boolean for "false".
The assignment seems pretty straightforward.
 
Last edited:
  • #3


Hi there,

Sequence in this context refers to a consecutive order of numbers or objects. In this case, we are looking for a sequence of numbers in a set of cards.

To write a function in C that can determine if a set of cards has a sequence, we can use the following steps:

1. Define a function called sequence that takes in an array of cards as a parameter.

2. Inside the function, we can use a loop to iterate through the array of cards.

3. Create a variable that keeps track of the previous card's value. This will help us determine if the current card is in sequence with the previous one.

4. Use a switch statement to check the value of each card. Since ace can be considered as either before 2 or after king, we can handle this case by checking if the current card is an ace and if the previous card is a 2 or king.

5. If the current card is in sequence with the previous one, update the previous card's value to the current one.

6. If the current card is not in sequence with the previous one, return 0 (meaning there is no sequence).

7. After the loop, if all the cards were in sequence, return 1.

Some suggestions for writing the function could be to break down the problem into smaller steps, test your code with different sets of cards, and use comments to explain your thought process. Also, make sure to handle edge cases such as when the set of cards is empty or if there are duplicate cards.

I hope this helps! Good luck with your code.
 

What does sequence mean?

Sequence refers to the ordered arrangement of items or events in a particular pattern.

What are some examples of sequences?

Some examples of sequences include alphabetical order, numerical order, and the order of operations in math.

How is sequence used in scientific research?

Sequence is used in scientific research to organize and analyze data, identify patterns, and make predictions.

What are some strategies for organizing data in a sequence?

Some strategies for organizing data in a sequence include using a timeline, creating a flowchart, and using a table or graph.

Can you give me some suggestions for effectively using sequence in my research?

Some suggestions for effectively using sequence in research include clearly defining the sequence of events or steps in your experiment, double-checking the order of your data before analyzing it, and using visual aids to represent your data in a sequence. It is also important to consider the potential impact of any outliers or unexpected results on the overall sequence of your data.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
2
Views
847
Replies
3
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
4K
Replies
20
Views
5K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
1K
  • Calculus and Beyond Homework Help
Replies
5
Views
7K
  • Precalculus Mathematics Homework Help
Replies
7
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
Back
Top