The challenge
The shortest code by character count to output a best-case blackjack hand from the list of number-cards given.
Input is a list of numbers from 1 to 10 (inclusive) separated by space.
Output will be the best blackjack hand formed from that list of cards - the closest available combo to reach 21 by the sum of all card values without surpassing it. Cards can be removed but not added.
If a case where removing two or more cards in favor of one card to accomplish the same result (removing 5 or 4,1 to gain 21) removing the least cards is required.
If the equal amount of cards is to be removed (removing 1,4 or 3,2) the group with the minimum of the minimum will be removed (in the previous example, 1,4 will be removed as min(min(3,2), min(1,4))
belongs to that pair). In the case of duplicate cards, the first encounter should be removed.
Output will be formed as diamond cards, with input order preserved:
__________ __________ | || | | || /\ | | || \/ | | /\ || | | \/ || | | || /\ | | || \/ | |__________||__________| __________ __________ | || | | /\ || /\ /\ | | \/ || \/ \/ | | /\ || | | \/ || | | /\ || /\ /\ | | \/ || \/ \/ | |__________||__________| __________ __________ | || | | /\ /\ || /\ /\ | | \/ \/ || \/ \/ | | /\ || /\ /\ | | \/ || \/ \/ | | /\ /\ || /\ /\ | | \/ \/ || \/ \/ | |__________||__________| __________ __________ | || | | /\ /\ || /\ /\ | | \/ /\ \/ || \/ /\ \/ | | /\ \/ /\ || /\ \/ /\ | | \/ \/ || \/ /\ \/ | | /\ /\ || /\ \/ /\ | | \/ \/ || \/ \/ | |__________||__________| __________ __________ | /\ /\ || /\ /\ | | \/ \/ || \/ /\ \/ | | /\ /\ || /\ \/ /\ | | \/ /\ \/ || \/ \/ | | /\ \/ /\ || /\ /\ | | \/ \/ || \/ /\ \/ | | /\ /\ || /\ \/ /\ | |_\/____\/_||_\/____\/_|
Test cases
Input:
1 5 7 8
Output:
__________ __________ __________ __________
| || || || |
| || /\ /\ || /\ /\ || /\ /\ |
| || \/ \/ || \/ /\ \/ || \/ /\ \/ |
| /\ || /\ || /\ \/ /\ || /\ \/ /\ |
| \/ || \/ || \/ \/ || \/ /\ \/ |
| || /\ /\ || /\ /\ || /\ \/ /\ |
| || \/ \/ || \/ \/ || \/ \/ |
|__________||__________||__________||__________|
Input:
10 3 4 2 6
Output:
__________ __________ __________ __________
| /\ /\ || || || |
| \/ /\ \/ || /\ || /\ || /\ /\ |
| /\ \/ /\ || \/ || \/ || \/ \/ |
| \/ \/ || /\ || || /\ /\ |
| /\ /\ || \/ || || \/ \/ |
| \/ /\ \/ || /\ || /\ || /\ /\ |
| /\ \/ /\ || \/ || \/ || \/ \/ |
|_\/____\/_||__________||__________||__________|
Input
5 10 5 2 3
Output:
__________ __________ __________ __________
| /\ /\ || || || |
| \/ /\ \/ || /\ /\ || /\ || /\ |
| /\ \/ /\ || \/ \/ || \/ || \/ |
| \/ \/ || /\ || || /\ |
| /\ /\ || \/ || || \/ |
| \/ /\ \/ || /\ /\ || /\ || /\ |
| /\ \/ /\ || \/ \/ || \/ || \/ |
|_\/____\/_||__________||__________||__________|
Code count includes input/output (i.e full program).