Feature #2: Maximum Points You Can Obtain from Cards
Implementing the "Maximum Points You Can Obtain from Cards" feature for our "Game" project.
We'll cover the following
Description
In this scenario, you will be working on a custom card game named Fizzle. In Fizzle, the dealer shuffles the deck and spreads out all the cards facing upwards in a linear fashion. Then, players take turns rolling a dice. Suppose the number rolled is . Players will then take turns to remove cards from the deck, but the players can only pick cards from either the deck’s right or left side. Each player’s goal is to pick out the cards with maximum points. Each numbered card has points corresponding to its number, and the faced cards, jack, queen, king, and ace, have 11, 12, 13, and 14 points, respectively.
Our task is to create a feature for Fizzle’s computer player. We will be given the deck’s current state and the number the player rolled. We need to determine the maximum score that the player can obtain on that turn.
Let’s take a look at the following example:
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.