What sequence means and give me some suggestions

AI Thread Summary
The discussion centers on creating a C function that determines if a set of five cards forms a sequence, or straight, in poker terms. The valid sequence includes cards ranked from 2 to King, with Ace being flexible, either before 2 or after King. The first example provided, with cards two of diamonds, four of clubs, six of hearts, three of hearts, and five of spades, is a valid sequence, returning 1. In contrast, the second example, featuring two of spades, king of spades, ace of clubs, three of diamonds, and five of hearts, does not form a sequence and returns 0. The discussion clarifies that the function should return a boolean value, with 1 indicating a true sequence and 0 indicating false. The task is deemed straightforward, and the request is made to avoid using structures in the implementation.
brad sue
Messages
270
Reaction score
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
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:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top