Andyman's Golf Course - Hole 4 - Blackjack

View as PDF

Submit solution


Points: 0
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Python

For the fourth hole of AndyMan68's golf course, he would like you to simply play a game of Blackjack.

Unfortunately, AndyMan68 doesn't have a full deck, and only has 5 cards with various numbers on them. After shuffling, the cards are in some fixed order. You may repeatedly take cards in the order they are in until either there are no more cards or the sum of the values of your cards exceeds 21.

Being sneaky, you snuck a peek at the order of the cards after shuffling (typically the player does not know what card will be next, making it a game of luck). You then have to figure out how many cards you should accept before stopping, to ensure you don't exceed a total sum of 21 while being as close to it as possible.

Input Specification

There will be 5 positive integers ranging from 1 to 10 inclusive, each on their own separate line. This is the order in which the cards are received.

The final line will be -1 on its own line, to indicate the last of the input.

Note that it is not necessary to read in all lines of input.

Output Specification

Output the number of cards you can accept without exceeding 21, or output All if you can accept all 5.

Scoring

If the program has the correct output, you will receive a score of (for each test case):

  • 0 if the length of the code in bytes exceeds 120
  • 100 if the length of the code in bytes is less than 68
  • (168-N)\times \frac{68}{N} where N is the length of code in bytes, if 68\le N \le 120

Sample Input 1

5
2
7
5
3
-1

Sample Output 1

4

Explanation for Sample Output 1

You can accept the first 4 cards, which totals to 5+2+7+5=19. If you try to accept the 5th number, your total will increase to 22, which exceeds 21.

Sample Input 2

1
7
10
1
2
-1

Sample Output 2

All

Explanation for Sample Output 1

You can accept all 5 cards in this case.


Comments

There are no comments at the moment.