Card game algorithm

I was asked to develop a card game in c language between two players. Players can choose the leftmost or rightmost card from the card list:
If the list is: [2,14,12,6,20,10], the player can choose 2 or 10.
Finally, the player with the higher score (the number of cards selected by the player) wins the game.
Is there any way to optimize the player The choice, knowing that not always the best choice is the largest (for example: choosing 10 in the above situation provides other players with the opportunity to choose 20).
(Sounds like a recursive function…)
I don’t know how to maximize. But if (at the beginning) there are even-numbered cards, then the first player has a simple Algorithm:

First, mark the cards with red and black (alternately), so the cards on the edge will use different colors. Summarize (separately) the black card and the red card, and choose the color you like. Assuming (for example) the sum of black cards is higher, continue to choose black cards and your opponent will have to choose red cards-you will win!

I was asked to develop a card game in c language between two players. Players can choose the leftmost or rightmost card from the card list:
If the list is: [2,14,12,6,20,10], the player can choose 2 or 10.
Finally, the player with the higher score (the number of cards selected by the player) wins the game.
Yes There is no way to optimize the player’s choice, knowing that the best choice is not always the largest (for example: choosing 10 in the above situation provides other players with the opportunity to choose 20).
(Sounds like a recursive function… )

I don’t know how to maximize. But if (at the beginning) there are even-numbered cards, then the first player has a simple algorithm:

First, mark the cards with red and black (alternating), so the cards on the edges will adopt different colors. Summarize (individually) black cards and red cards, and choose the color you like. Assuming (for example) the sum of black cards Higher, continue to choose the black card, your opponent will have to choose the red card-you will win!

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1774 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.