Using the Deck Of Cards API (https://deckofcardsapi.com/), write a program that does the following:
- Create a new shuffled deck
- Draw cards one at a time from the deck
- When a card is drawn, print it out in any format that includes number and suit (e.g. "JACK of SPADES" or "7H")
- If any three consecutive cards add up to a value of 21 using blackjack rules (see below), exit the program
- If all cards are drawn from the deck and no three consecutive cards add up to a value of 21, print "no more cards"
The "blackjack value" of a card can be defined as follows:
- For numbered cards 2-10 (inclusive): the value is the number on the card
- For JACK, QUEEN, KING: the value is 10
- For ACE: the value is 1 or 11
Part 2:
How would you refactor the code to detect any sequence of cards adding to 21? For example, if I drew the following cards in order: ACE, ACE, ACE, ACE, 2, 2, 2, 2, 9, then the program would exit because all of the aces would be interpreted as having a value of 1 and thus 1+1+1+1+2+2+2+2+9=21