Question: . Name: calcLikenessscore () Parameters (Please Follow the same Order): segi (string) - The First Sequence seq2 (string) - The Second Sequence Return Value: The








. Name: calcLikenessscore () Parameters (Please Follow the same Order): segi (string) - The First Sequence seq2 (string) - The Second Sequence Return Value: The Likeness Score - likeness_score (double) The parameters seqi and seq2 should be of the same length for the function to calculate the Likeness Score. Else the Likeness Score returned should be -1. The function should not print anything. O . O Examples: Parameters and their expected Likeness Score which the function should return segi seq2 likeness_score S7H8CJD 9HA S7H8CJD 9HA 6 C4DTSK C4DBSK 3 HQDASJ DAD SJ 1.67 HJDKC3 C3HJDK 0 D7H2 S4 HSDTS805 -1 The file should be named as calcLikenessScore.cpp. Once you have tested your code on VS Code, then head over to Coderunner on Canvas and paste only your function in the answer box! Hint: Remember when you write a for loop, you can increment the value of the counter variable by any value and not just 1. Question 5: bestLikenessScore () (8 points) Write a function called bestLikenessscore () that is going to find the best Likeness Score between all the subsequences of a sequence (whose length is greater than or equal to the Golden Sequence) and the Golden Sequence. This function finds the maximum possible score a player could have. . Function Specifications: Name: bestLikeness score () Parameters (Please Follow the same Order): segi (string) - The Player's Sequence (length greater than or equal to Golden Sequence) o gold_seg (string) - The Golden Sequence Return Value: Best Likeness Score - best_likeness_score (double) Length of seqi should be greater than or equal to gold_seg for the function to calculate the Best Likeness Score. If not, return -1. . . Compare the sub-sequences from the player's sequence to the Golden Sequence to find the Best Likeness Score among all the sub-sequences. Use the previous calcLikenessscore () function from Question 4 to find the Likeness Score once the sub-sequence is obtained. The function should not print anything. . Example: Expected output from a Longer Player's Sequence and the Golden Sequence segi seg2 likeness_score S7H8SJD 9HXCJD9 0 S7H8SJD 9H8CJD9 1.67 S7H8SJD 9H8CJD9 H8C6D6 0 S7H8SJD9H8CJD9 0 S7H8SJD 9HXCJD 9 2 The function should calculate the Likeness Score between all the b-sequences and the Golden Sequence and should return only the Best Likeness Score as indicated. In the example above, the last subsequence has the highest score, 2, and therefore 2 should be the return value. The file should be named as bestLikenessScore.cpp. Once you have tested your code on VS Code, then head over to coderunner on Canvas and paste only your function in the answer box! Question 6: findWinner () (7 points) Write a function called findWinner() that is going to find the Winner among 3 players and display the winner in the console. The players have the option to pick a maximum of 10 cards and form their sequences. It is not necessary for the players to choose the same number of cards. These sequences are passed into the function as segi, seg2, seq3. The length of the Golden Sequence will always be lesser than or equal to the length of the smallest sequence among the 3 players. Function Specifications: Name: findwinner() Parameters (Please Follow the same Order): segi (string) - Player 1 Sequence seq2 (string) - Player 2 Sequence seq3 (string) - Player 3 Sequence gold_seg (string) - The Golden Sequence Return Value: No Return value. Output: O Remember, that in order for a player to win his/her score should be greater than 0. If all three players have a score of O then there is no winner and the function should print "Better luck next time everyone!" If all the three players have the same score, then the function should print "Congratulations everyone! You have all won!" If there are two players with the same best score, the function should print Congratulations Players # and #! You have won! where the #s represent the winning players. If there is a clear winner, then the function should print "Congratulations Player #! You have won!", where # is either 1, 2 or 3. Remember the sequences segi, seg2 and seq3 of the players need not be of the same length, i.e., they need not pick the same number of cards. Use the previous bestLikenessscore () function from Question 5 to find the Best Likeness Score in the entire sequence of the player. Examples: Case1: All players with a score of 0: Player # seq# gold_seq Best Likeness Score 1 CAH755CJCK 0 2 S7H9SQCA D4D 5D 6 0 3 H2S6H7CTS 9HK 0 EXPECTED OUTPUT Better luck next time everyone! Case2: All players with same Best Likeness Score: Player # seq# gold_seq Best Likeness Score 1 DAH755CJ 0.33 2 S7H9DQCA D4D 5D 6 0.33 3 H2S 6CTD 7 0.33 EXPECTED OUTPUT Congratulations everyone! You have on! Case3: Two players with same Best Likeness Score: Player # seq# gold_seq Best Likeness Score 1 DAH755CJ 0.33 DTD2D 3 2 S7D2DQCAH7 1.67 3 H2DTCTD 75 8C5 1.67 EXPECTED OUTPUT Congratulations Players 2 and 3! You have won! Case4: Clear Winner with the Best Likeness Score: Player # seg# gold_sea Best Likeness Score 1 H2DTHTSAS 7CA 3 2 D7H2 SQCAH7 DTH7SA 1 3 CJDAH 705 1.67 EXPECTED OUTPUT Congratulations Player 1! You have won! The file should be named as findWinner.cpp. Once you have tested your code on VS Code, then head over to coderunner on Canvas and paste only your function in the answer box! Question 7: Putting it all together using main() (5 points) In this question, you will be writing a main() driver function through which you will give the end user the option to choose from the following options: Calculate the Likeness Score between two sequences of equal length Find the Best Likeness Score between two sequences of unequal length Find the Winner among the sequences of 3 players and the Golden Sequence Exit The menu will run on a loop, continually offering the user four options until they opt to quit. You need to fill in the code for each of the options. Be sure to use the functions you wrote in questions 4-6 Below is an Sample Run of the main program depicting different cases: (Text in Bold represents User Input) ---- Menu ---- 1: Calculate the likeness Score between 2 strings of equal length. 2: Calculate the Best Likeness score between 2 sequences of possibly different length. 3: Find the winner among sequences of 3 players and a Golden Sequence. 4: Exit. Enter your choice (1-4): DECK OF CARDS The standard 52-card deck of French-suited playing cards is the most common pack of playing cards used today. A standard 52-card pack comprises 13 ranks in each of the four French suits: Clubs (1), Diamonds (), Hearts () and Spades), with reversible (double-headed) court cards (face cards). Each suit includes an Ace, a King, Queen and Jack, each depicted alongside a symbol of its suit, and numerals or pip cards from the Deuce (Two) to the Ten, with each card depicting that many symbols (pips) of its suit. Example set of 52 playing cards; 13 of each suit: clubs, diamonds, hearts, and spades 3 4 5 6 7 8 9 10 Jack Queen King Ace N 3 5 + Clubs Diamonds > Hearts 8 Spades Ref: Standard 52-Card Deck SEQUENCE OF CARDS John, Mike and Suzy head to the Carnival at Zootopia. They come across a stall named "Can You Pick 'em Right?l. The stall owner Mr X greets them and invites them to play his game and tells them that the winner will get a coupon worth $50 to spend in the Carnival. The three friends get excited and decide to play the game. Mr X starts to explain the game to the participants. The ultimate aim of the game is for the players to create a sequence by picking a set of cards which is similar to the sequence picked by the host, i.e., Mr X. He says that every player is free to choose up to a maximum of 10 cards to form their sequence. A sequence is formed by the cards picked by the players. The players select a subsequence of cards from their hand to compare against the golden sequence. The players cannot rearrange the cards, but can select a continuous subset that is the same length as the golden sequence. The game is played with multiple decks of cards. We know that in a deck of cards there are four suits: Spades (S), Hearts (H), Diamonds (D) and Clubs (C). And there are 13 ranks in each suit: Ace, 2-10, Jack, Queen and King. For the purpose of creating the sequence Ace is treated as the character A. Ten as T, Jack as J, Queen as Q and King as K. . Formation of Sequences: First, the card's suit is taken and the letter representing that suit is added to the sequence Next, the card's rank is taken and appended to the sequence. Similarly, the process is repeated for all the cards picked by the player in the order that they pick the cards. Let us assume that John has picked the following cards: Ace of Diamonds, 5 of Hearts, Ten of Spades, Queen of Clubs and the 6 of Hearts in the same order as specified. Therefore the sequence generated by John is as follows: DAH5STCQH6 Each player picks a maximum of 10 cards from which they can create their sequence. Once all the players have picked their cards, Mr X chooses his sequence of cards (without any knowledge of the cards picked by the players), which is going to be the Golden Sequence of cards. Mr. X can choose any number of cards less than or equal to 10. Let us assume that Mr X picks the following cards. Ace of Diamonds, 4 of Hearts, Ten of Spades, 8 of Hearts and 6 of Clubs. So the Golden Sequence is as follows: DAH4 STH8C6 Once the Golden Sequence is found, a Likeness Score between the sequences of the players and the Golden Sequence is found. And finally, the player with the highest Likeness Score is declared the winner. Rules for Likeness Score: While finding the Likeness Score, more priority is given to the Suit of the cards rather than the Rank of the card. Rules include: First, the number of cards under consideration in the player's sequence and the Golden Sequence must be the same. So if the player has picked 10 cards, while the Golden Sequence has only 5 cards, then sub-sequences of 5 cards from the original sequence must be obtained. Something like this: Player's Sub-Sequences to be considered Golden Sequence HAD2S3C4H5D6S7C8H9CT HAD2s3C4H5D6S7C8H9CT HAD2s3C4H5D6S7C8H9CT H6C8SJDKS3 HAD2 S3C4H5D6S7C8H9CT HAD2s3C4H5D6S7C8H9CT HAD2S3C4H5D6S7C8H9CT When the two sequences to be considered are available, o The suit of the first card in both sequences are taken into account. If the suit is the same, then we keep track of those positions where the suit of the card is the same. o Next, if and only if the suit of the cards under consideration is the same, we look at the rank of the card. If the rank of the cards are also the same, a bonus point of 1 (for every such match) is added in the calculation of the Likeness Score. o Finally, once all the cards have been compared, the overall Likeness Score is calculated as follows: Likeness Score (Number of Cards where the suit is same / Number of Cards ) + ( 1 * Number of Cards with Same Suit and Same Rank) Example: Let us look at John's sequence and the Golden Sequence Cards #1 #2 #3 #4 #5 Player Sequence/Sub-Sequence D A H 5 STCO H6 | 1 | +1 X X Golden Sequence D A H 4 S T H 8 C 6 +1 +0 Not Considered as suit is different; leading to no bonus although rank is same Not Considered as suit is different; leading to no bonus Considered; +1 bonus added as suit and rank are same Considered; no bonus although same suit Therefore 3 Likeness Score = 5 + 2 = 2.6 Thus, the Range of the Likeness Scores is: [0, 1 + Number of Cards in Sequences] In this project (Questions 4-7) you will be creating an interactive program in C++ to allow users to play this game by implementing the following features: Q4: calcLikenessScore () - A function to calculate the likeness between two sequences of equal length Q5: bestLikenessScore () - A function to calculate the best Likeness Score among all the sub-sequences in a sequence and a given Golden Sequence Q6: findWinner() - A function to find the winner among 3 players whose sequence has the best Likeness Score with the Golden Sequence. Q7: Putting it All Together - Write a main() function that is going to call all the three functions created above to make the players play the game. You're welcome to write additional helper functions as you need. Write your code and test each function on your VS Code. Then, once finished, you can submit it on Canvas coderunner to make sure it's fully functional. All the functions and the main function should be in one file, SequenceOfCards.cpp . Name: calcLikenessscore () Parameters (Please Follow the same Order): segi (string) - The First Sequence seq2 (string) - The Second Sequence Return Value: The Likeness Score - likeness_score (double) The parameters seqi and seq2 should be of the same length for the function to calculate the Likeness Score. Else the Likeness Score returned should be -1. The function should not print anything. O . O Examples: Parameters and their expected Likeness Score which the function should return segi seq2 likeness_score S7H8CJD 9HA S7H8CJD 9HA 6 C4DTSK C4DBSK 3 HQDASJ DAD SJ 1.67 HJDKC3 C3HJDK 0 D7H2 S4 HSDTS805 -1 The file should be named as calcLikenessScore.cpp. Once you have tested your code on VS Code, then head over to Coderunner on Canvas and paste only your function in the answer box! Hint: Remember when you write a for loop, you can increment the value of the counter variable by any value and not just 1. Question 5: bestLikenessScore () (8 points) Write a function called bestLikenessscore () that is going to find the best Likeness Score between all the subsequences of a sequence (whose length is greater than or equal to the Golden Sequence) and the Golden Sequence. This function finds the maximum possible score a player could have. . Function Specifications: Name: bestLikeness score () Parameters (Please Follow the same Order): segi (string) - The Player's Sequence (length greater than or equal to Golden Sequence) o gold_seg (string) - The Golden Sequence Return Value: Best Likeness Score - best_likeness_score (double) Length of seqi should be greater than or equal to gold_seg for the function to calculate the Best Likeness Score. If not, return -1. . . Compare the sub-sequences from the player's sequence to the Golden Sequence to find the Best Likeness Score among all the sub-sequences. Use the previous calcLikenessscore () function from Question 4 to find the Likeness Score once the sub-sequence is obtained. The function should not print anything. . Example: Expected output from a Longer Player's Sequence and the Golden Sequence segi seg2 likeness_score S7H8SJD 9HXCJD9 0 S7H8SJD 9H8CJD9 1.67 S7H8SJD 9H8CJD9 H8C6D6 0 S7H8SJD9H8CJD9 0 S7H8SJD 9HXCJD 9 2 The function should calculate the Likeness Score between all the b-sequences and the Golden Sequence and should return only the Best Likeness Score as indicated. In the example above, the last subsequence has the highest score, 2, and therefore 2 should be the return value. The file should be named as bestLikenessScore.cpp. Once you have tested your code on VS Code, then head over to coderunner on Canvas and paste only your function in the answer box! Question 6: findWinner () (7 points) Write a function called findWinner() that is going to find the Winner among 3 players and display the winner in the console. The players have the option to pick a maximum of 10 cards and form their sequences. It is not necessary for the players to choose the same number of cards. These sequences are passed into the function as segi, seg2, seq3. The length of the Golden Sequence will always be lesser than or equal to the length of the smallest sequence among the 3 players. Function Specifications: Name: findwinner() Parameters (Please Follow the same Order): segi (string) - Player 1 Sequence seq2 (string) - Player 2 Sequence seq3 (string) - Player 3 Sequence gold_seg (string) - The Golden Sequence Return Value: No Return value. Output: O Remember, that in order for a player to win his/her score should be greater than 0. If all three players have a score of O then there is no winner and the function should print "Better luck next time everyone!" If all the three players have the same score, then the function should print "Congratulations everyone! You have all won!" If there are two players with the same best score, the function should print Congratulations Players # and #! You have won! where the #s represent the winning players. If there is a clear winner, then the function should print "Congratulations Player #! You have won!", where # is either 1, 2 or 3. Remember the sequences segi, seg2 and seq3 of the players need not be of the same length, i.e., they need not pick the same number of cards. Use the previous bestLikenessscore () function from Question 5 to find the Best Likeness Score in the entire sequence of the player. Examples: Case1: All players with a score of 0: Player # seq# gold_seq Best Likeness Score 1 CAH755CJCK 0 2 S7H9SQCA D4D 5D 6 0 3 H2S6H7CTS 9HK 0 EXPECTED OUTPUT Better luck next time everyone! Case2: All players with same Best Likeness Score: Player # seq# gold_seq Best Likeness Score 1 DAH755CJ 0.33 2 S7H9DQCA D4D 5D 6 0.33 3 H2S 6CTD 7 0.33 EXPECTED OUTPUT Congratulations everyone! You have on! Case3: Two players with same Best Likeness Score: Player # seq# gold_seq Best Likeness Score 1 DAH755CJ 0.33 DTD2D 3 2 S7D2DQCAH7 1.67 3 H2DTCTD 75 8C5 1.67 EXPECTED OUTPUT Congratulations Players 2 and 3! You have won! Case4: Clear Winner with the Best Likeness Score: Player # seg# gold_sea Best Likeness Score 1 H2DTHTSAS 7CA 3 2 D7H2 SQCAH7 DTH7SA 1 3 CJDAH 705 1.67 EXPECTED OUTPUT Congratulations Player 1! You have won! The file should be named as findWinner.cpp. Once you have tested your code on VS Code, then head over to coderunner on Canvas and paste only your function in the answer box! Question 7: Putting it all together using main() (5 points) In this question, you will be writing a main() driver function through which you will give the end user the option to choose from the following options: Calculate the Likeness Score between two sequences of equal length Find the Best Likeness Score between two sequences of unequal length Find the Winner among the sequences of 3 players and the Golden Sequence Exit The menu will run on a loop, continually offering the user four options until they opt to quit. You need to fill in the code for each of the options. Be sure to use the functions you wrote in questions 4-6 Below is an Sample Run of the main program depicting different cases: (Text in Bold represents User Input) ---- Menu ---- 1: Calculate the likeness Score between 2 strings of equal length. 2: Calculate the Best Likeness score between 2 sequences of possibly different length. 3: Find the winner among sequences of 3 players and a Golden Sequence. 4: Exit. Enter your choice (1-4): DECK OF CARDS The standard 52-card deck of French-suited playing cards is the most common pack of playing cards used today. A standard 52-card pack comprises 13 ranks in each of the four French suits: Clubs (1), Diamonds (), Hearts () and Spades), with reversible (double-headed) court cards (face cards). Each suit includes an Ace, a King, Queen and Jack, each depicted alongside a symbol of its suit, and numerals or pip cards from the Deuce (Two) to the Ten, with each card depicting that many symbols (pips) of its suit. Example set of 52 playing cards; 13 of each suit: clubs, diamonds, hearts, and spades 3 4 5 6 7 8 9 10 Jack Queen King Ace N 3 5 + Clubs Diamonds > Hearts 8 Spades Ref: Standard 52-Card Deck SEQUENCE OF CARDS John, Mike and Suzy head to the Carnival at Zootopia. They come across a stall named "Can You Pick 'em Right?l. The stall owner Mr X greets them and invites them to play his game and tells them that the winner will get a coupon worth $50 to spend in the Carnival. The three friends get excited and decide to play the game. Mr X starts to explain the game to the participants. The ultimate aim of the game is for the players to create a sequence by picking a set of cards which is similar to the sequence picked by the host, i.e., Mr X. He says that every player is free to choose up to a maximum of 10 cards to form their sequence. A sequence is formed by the cards picked by the players. The players select a subsequence of cards from their hand to compare against the golden sequence. The players cannot rearrange the cards, but can select a continuous subset that is the same length as the golden sequence. The game is played with multiple decks of cards. We know that in a deck of cards there are four suits: Spades (S), Hearts (H), Diamonds (D) and Clubs (C). And there are 13 ranks in each suit: Ace, 2-10, Jack, Queen and King. For the purpose of creating the sequence Ace is treated as the character A. Ten as T, Jack as J, Queen as Q and King as K. . Formation of Sequences: First, the card's suit is taken and the letter representing that suit is added to the sequence Next, the card's rank is taken and appended to the sequence. Similarly, the process is repeated for all the cards picked by the player in the order that they pick the cards. Let us assume that John has picked the following cards: Ace of Diamonds, 5 of Hearts, Ten of Spades, Queen of Clubs and the 6 of Hearts in the same order as specified. Therefore the sequence generated by John is as follows: DAH5STCQH6 Each player picks a maximum of 10 cards from which they can create their sequence. Once all the players have picked their cards, Mr X chooses his sequence of cards (without any knowledge of the cards picked by the players), which is going to be the Golden Sequence of cards. Mr. X can choose any number of cards less than or equal to 10. Let us assume that Mr X picks the following cards. Ace of Diamonds, 4 of Hearts, Ten of Spades, 8 of Hearts and 6 of Clubs. So the Golden Sequence is as follows: DAH4 STH8C6 Once the Golden Sequence is found, a Likeness Score between the sequences of the players and the Golden Sequence is found. And finally, the player with the highest Likeness Score is declared the winner. Rules for Likeness Score: While finding the Likeness Score, more priority is given to the Suit of the cards rather than the Rank of the card. Rules include: First, the number of cards under consideration in the player's sequence and the Golden Sequence must be the same. So if the player has picked 10 cards, while the Golden Sequence has only 5 cards, then sub-sequences of 5 cards from the original sequence must be obtained. Something like this: Player's Sub-Sequences to be considered Golden Sequence HAD2S3C4H5D6S7C8H9CT HAD2s3C4H5D6S7C8H9CT HAD2s3C4H5D6S7C8H9CT H6C8SJDKS3 HAD2 S3C4H5D6S7C8H9CT HAD2s3C4H5D6S7C8H9CT HAD2S3C4H5D6S7C8H9CT When the two sequences to be considered are available, o The suit of the first card in both sequences are taken into account. If the suit is the same, then we keep track of those positions where the suit of the card is the same. o Next, if and only if the suit of the cards under consideration is the same, we look at the rank of the card. If the rank of the cards are also the same, a bonus point of 1 (for every such match) is added in the calculation of the Likeness Score. o Finally, once all the cards have been compared, the overall Likeness Score is calculated as follows: Likeness Score (Number of Cards where the suit is same / Number of Cards ) + ( 1 * Number of Cards with Same Suit and Same Rank) Example: Let us look at John's sequence and the Golden Sequence Cards #1 #2 #3 #4 #5 Player Sequence/Sub-Sequence D A H 5 STCO H6 | 1 | +1 X X Golden Sequence D A H 4 S T H 8 C 6 +1 +0 Not Considered as suit is different; leading to no bonus although rank is same Not Considered as suit is different; leading to no bonus Considered; +1 bonus added as suit and rank are same Considered; no bonus although same suit Therefore 3 Likeness Score = 5 + 2 = 2.6 Thus, the Range of the Likeness Scores is: [0, 1 + Number of Cards in Sequences] In this project (Questions 4-7) you will be creating an interactive program in C++ to allow users to play this game by implementing the following features: Q4: calcLikenessScore () - A function to calculate the likeness between two sequences of equal length Q5: bestLikenessScore () - A function to calculate the best Likeness Score among all the sub-sequences in a sequence and a given Golden Sequence Q6: findWinner() - A function to find the winner among 3 players whose sequence has the best Likeness Score with the Golden Sequence. Q7: Putting it All Together - Write a main() function that is going to call all the three functions created above to make the players play the game. You're welcome to write additional helper functions as you need. Write your code and test each function on your VS Code. Then, once finished, you can submit it on Canvas coderunner to make sure it's fully functional. All the functions and the main function should be in one file, SequenceOfCards.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
