What is the score of my Scopa hand?Score a Cribbage HandCompare two poker handsProbability to win a hand of poker (Texas hold 'em)Simple Pazaak (Star Wars Card Game from Knights of the Old Republic)Evaluate a Skat-HandCalculate Doppelkopf ScoreBridge Hand ScoringDetermine the winner of a game of WarScore a hand of HeartsGolf (6-card) Golf!

Can I cast Death Ward on additional creatures without causing previous castings to end?

How dangerous is a very out-of-true disc brake wheel?

Does the US Armed Forces refuse to recruit anyone with an IQ less than 83?

Re-entering the UK after overstaying in 2008

How to "Start as close to the end as possible", and why to do so?

What is the difference between increasing volume and increasing gain?

How important is knowledge of trig identities for use in Calculus

How closely correlated is culture to geography?

Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?

How deep is the liquid in a half-full hemisphere?

Drawing Maps; flat distortion

Is there a pattern for handling conflicting function parameters?

Why most footers have a background color as a divider of section?

Do jackscrews suffer from blowdown?

SOQL injection vulnerability issue

How to identify whether a publisher is genuine or not?

Lighthouse Alternatives

Did the Soviet army intentionally send troops (e.g. penal battalions) running over minefields?

Why not add cuspidal curves in the moduli space of stable curves?

How can Germany increase investments in Russia while EU economic sanctions against Russia are still in place?

Wondering why they used ultrafast diodes in a 50 or 60Hz bridge?

Parent asking for money after moving out

Why do Russians sometimes spell "жирный" (fatty) as "жырный"?

Would a horse be sufficient buffer to prevent injury when falling from a great height?



What is the score of my Scopa hand?


Score a Cribbage HandCompare two poker handsProbability to win a hand of poker (Texas hold 'em)Simple Pazaak (Star Wars Card Game from Knights of the Old Republic)Evaluate a Skat-HandCalculate Doppelkopf ScoreBridge Hand ScoringDetermine the winner of a game of WarScore a hand of HeartsGolf (6-card) Golf!






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









4












$begingroup$


I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon.



The challenge: figure out the number of points scored in a round of Scopa, given the cards the player captured during the round as input.



There are 40 cards in a Scopa deck. If you are using an international deck you remove the 8s, 9s, and 10s, leaving A,2,3,4,5,6,7,Q,J,K in each suit.1 There are two players or partnerships, and after every round, all cards end up captured by one or the other of the two players. The score is counted as follows (more information here):



  • The player with the most cards scores 1 point.

  • The player with the most diamonds (or coins if using the Italian deck) scores 1 point.

  • The player with the 7 of diamonds (or coins), known as the sette bello or beautiful seven, scores 1 point.

  • The player with the highest primiera scores 1 point. A player's primiera score is the sum of the scores of the highest-value card that the player captured in each suit (see table below). If you do not have at least one card in every suit, you lose by default even if your score would exceed your opponent's score. In the exceedingly rare case that neither player has at least one card in every suit, the player with the higher primiera total scores the point.2

Table of primiera scores



| Rank | Value |
| ----- | ----- |
| 7 | 21 |
| 6 | 18 |
| A | 16 |
| 5 | 15 |
| 4 | 14 |
| 3 | 13 |
| 2 | 12 |
| Q,J,K | 10 |


So a player can score at most 4 points in a round.3 If there is a tie, which is possible for cards, diamonds, or primiera, no one scores the point.



It's important to realize that since each card must be captured by one of the two players, you can infer what cards the other player must have taken even if you only know what cards one player took. You will need to do this to correctly score primiera.



Challenge rules



Input



Your code should take as input the cards captured by a single player during a round of Scopa.



Input must be in string format, in which one character represents the rank of each card and one character its suit. This removes the potential loophole of passing the primiera scores in directly as input. Conversion of card ranks to primiera scores must be done in the program. However you may choose to use a single string separated by spaces or commas, an array of strings, or any other format. For example if you choose to encode ranks as 76A5432QJK and suits as DCHS you could use inputs such as ['7D', '6H', 'QD', 'JS'] or '7D,6H,QD,JS'.



Output



An integer from 0 to 4 representing the player's score.



Winning



Shortest answer in bytes wins!



Test cases



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "7C", "6C", "4C", "3C", "2C", "7H", "4H", "2H", "5S", "3S", "QS", "JS", "KS"]



Scores 4: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for the 7 of diamonds, and 1 point for scoring 78 in primiera (7,7,7,5 where opponent has 7,6,6,6 for 75)



["3D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "QC", "4H", "7S"]



Scores 0: <=20 cards, <=5 diamonds, no 7 of diamonds, and only scores 69 in primiera (7,7,4,3 where opponent has 7,7,6,K for 70)



[7D", "6D", "AD", "5D", "4D", "3D", "2D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "7H", "6H", "AH", "5H", "4H", "3H", "2H"]



Scores 3: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera would be 63 (7,7,7) and the opponent can only score 51 (7,Q,Q,Q) but since this hand has no spades it loses the point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH", "QS"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera only scores 51 (7,Q,Q,Q) and the opponent can score 63 (7,7,7) but since the opponent's hand has no diamonds this hand wins the primiera point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "7C", "7H"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. Even though this hand has no spades, it still wins primiera by a score of 63 to 57 (7,7,7 versus 7,6,6) because the opponent's hand has no diamonds.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH"]



Scores 2: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. This hand has no spades, and opponent's hand has no diamonds. Opponent wins primiera by a score of 63 to 41 (7,7,7 versus 7,Q,Q).



[] (empty array)



Scores 0




1: At least in our family, Jack outranks Queen in Scopa but this is irrelevant for scoring purposes.



2: I've been playing this game since childhood and have never seen that happen but your code had better be able to handle that case!



3: There are bonus points for "sweeps" scored during the round which I am ignoring for the purpose of this challenge.










share|improve this question









$endgroup$













  • $begingroup$
    Does each rank have to be represented by a distinct character?
    $endgroup$
    – Doorknob
    8 hours ago










  • $begingroup$
    @Doorknob No not necessarily, but at least in the solution I am working on I found it necessary to have a unique character for each rank to get all the test cases right.
    $endgroup$
    – qdread
    8 hours ago

















4












$begingroup$


I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon.



The challenge: figure out the number of points scored in a round of Scopa, given the cards the player captured during the round as input.



There are 40 cards in a Scopa deck. If you are using an international deck you remove the 8s, 9s, and 10s, leaving A,2,3,4,5,6,7,Q,J,K in each suit.1 There are two players or partnerships, and after every round, all cards end up captured by one or the other of the two players. The score is counted as follows (more information here):



  • The player with the most cards scores 1 point.

  • The player with the most diamonds (or coins if using the Italian deck) scores 1 point.

  • The player with the 7 of diamonds (or coins), known as the sette bello or beautiful seven, scores 1 point.

  • The player with the highest primiera scores 1 point. A player's primiera score is the sum of the scores of the highest-value card that the player captured in each suit (see table below). If you do not have at least one card in every suit, you lose by default even if your score would exceed your opponent's score. In the exceedingly rare case that neither player has at least one card in every suit, the player with the higher primiera total scores the point.2

Table of primiera scores



| Rank | Value |
| ----- | ----- |
| 7 | 21 |
| 6 | 18 |
| A | 16 |
| 5 | 15 |
| 4 | 14 |
| 3 | 13 |
| 2 | 12 |
| Q,J,K | 10 |


So a player can score at most 4 points in a round.3 If there is a tie, which is possible for cards, diamonds, or primiera, no one scores the point.



It's important to realize that since each card must be captured by one of the two players, you can infer what cards the other player must have taken even if you only know what cards one player took. You will need to do this to correctly score primiera.



Challenge rules



Input



Your code should take as input the cards captured by a single player during a round of Scopa.



Input must be in string format, in which one character represents the rank of each card and one character its suit. This removes the potential loophole of passing the primiera scores in directly as input. Conversion of card ranks to primiera scores must be done in the program. However you may choose to use a single string separated by spaces or commas, an array of strings, or any other format. For example if you choose to encode ranks as 76A5432QJK and suits as DCHS you could use inputs such as ['7D', '6H', 'QD', 'JS'] or '7D,6H,QD,JS'.



Output



An integer from 0 to 4 representing the player's score.



Winning



Shortest answer in bytes wins!



Test cases



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "7C", "6C", "4C", "3C", "2C", "7H", "4H", "2H", "5S", "3S", "QS", "JS", "KS"]



Scores 4: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for the 7 of diamonds, and 1 point for scoring 78 in primiera (7,7,7,5 where opponent has 7,6,6,6 for 75)



["3D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "QC", "4H", "7S"]



Scores 0: <=20 cards, <=5 diamonds, no 7 of diamonds, and only scores 69 in primiera (7,7,4,3 where opponent has 7,7,6,K for 70)



[7D", "6D", "AD", "5D", "4D", "3D", "2D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "7H", "6H", "AH", "5H", "4H", "3H", "2H"]



Scores 3: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera would be 63 (7,7,7) and the opponent can only score 51 (7,Q,Q,Q) but since this hand has no spades it loses the point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH", "QS"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera only scores 51 (7,Q,Q,Q) and the opponent can score 63 (7,7,7) but since the opponent's hand has no diamonds this hand wins the primiera point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "7C", "7H"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. Even though this hand has no spades, it still wins primiera by a score of 63 to 57 (7,7,7 versus 7,6,6) because the opponent's hand has no diamonds.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH"]



Scores 2: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. This hand has no spades, and opponent's hand has no diamonds. Opponent wins primiera by a score of 63 to 41 (7,7,7 versus 7,Q,Q).



[] (empty array)



Scores 0




1: At least in our family, Jack outranks Queen in Scopa but this is irrelevant for scoring purposes.



2: I've been playing this game since childhood and have never seen that happen but your code had better be able to handle that case!



3: There are bonus points for "sweeps" scored during the round which I am ignoring for the purpose of this challenge.










share|improve this question









$endgroup$













  • $begingroup$
    Does each rank have to be represented by a distinct character?
    $endgroup$
    – Doorknob
    8 hours ago










  • $begingroup$
    @Doorknob No not necessarily, but at least in the solution I am working on I found it necessary to have a unique character for each rank to get all the test cases right.
    $endgroup$
    – qdread
    8 hours ago













4












4








4





$begingroup$


I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon.



The challenge: figure out the number of points scored in a round of Scopa, given the cards the player captured during the round as input.



There are 40 cards in a Scopa deck. If you are using an international deck you remove the 8s, 9s, and 10s, leaving A,2,3,4,5,6,7,Q,J,K in each suit.1 There are two players or partnerships, and after every round, all cards end up captured by one or the other of the two players. The score is counted as follows (more information here):



  • The player with the most cards scores 1 point.

  • The player with the most diamonds (or coins if using the Italian deck) scores 1 point.

  • The player with the 7 of diamonds (or coins), known as the sette bello or beautiful seven, scores 1 point.

  • The player with the highest primiera scores 1 point. A player's primiera score is the sum of the scores of the highest-value card that the player captured in each suit (see table below). If you do not have at least one card in every suit, you lose by default even if your score would exceed your opponent's score. In the exceedingly rare case that neither player has at least one card in every suit, the player with the higher primiera total scores the point.2

Table of primiera scores



| Rank | Value |
| ----- | ----- |
| 7 | 21 |
| 6 | 18 |
| A | 16 |
| 5 | 15 |
| 4 | 14 |
| 3 | 13 |
| 2 | 12 |
| Q,J,K | 10 |


So a player can score at most 4 points in a round.3 If there is a tie, which is possible for cards, diamonds, or primiera, no one scores the point.



It's important to realize that since each card must be captured by one of the two players, you can infer what cards the other player must have taken even if you only know what cards one player took. You will need to do this to correctly score primiera.



Challenge rules



Input



Your code should take as input the cards captured by a single player during a round of Scopa.



Input must be in string format, in which one character represents the rank of each card and one character its suit. This removes the potential loophole of passing the primiera scores in directly as input. Conversion of card ranks to primiera scores must be done in the program. However you may choose to use a single string separated by spaces or commas, an array of strings, or any other format. For example if you choose to encode ranks as 76A5432QJK and suits as DCHS you could use inputs such as ['7D', '6H', 'QD', 'JS'] or '7D,6H,QD,JS'.



Output



An integer from 0 to 4 representing the player's score.



Winning



Shortest answer in bytes wins!



Test cases



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "7C", "6C", "4C", "3C", "2C", "7H", "4H", "2H", "5S", "3S", "QS", "JS", "KS"]



Scores 4: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for the 7 of diamonds, and 1 point for scoring 78 in primiera (7,7,7,5 where opponent has 7,6,6,6 for 75)



["3D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "QC", "4H", "7S"]



Scores 0: <=20 cards, <=5 diamonds, no 7 of diamonds, and only scores 69 in primiera (7,7,4,3 where opponent has 7,7,6,K for 70)



[7D", "6D", "AD", "5D", "4D", "3D", "2D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "7H", "6H", "AH", "5H", "4H", "3H", "2H"]



Scores 3: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera would be 63 (7,7,7) and the opponent can only score 51 (7,Q,Q,Q) but since this hand has no spades it loses the point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH", "QS"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera only scores 51 (7,Q,Q,Q) and the opponent can score 63 (7,7,7) but since the opponent's hand has no diamonds this hand wins the primiera point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "7C", "7H"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. Even though this hand has no spades, it still wins primiera by a score of 63 to 57 (7,7,7 versus 7,6,6) because the opponent's hand has no diamonds.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH"]



Scores 2: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. This hand has no spades, and opponent's hand has no diamonds. Opponent wins primiera by a score of 63 to 41 (7,7,7 versus 7,Q,Q).



[] (empty array)



Scores 0




1: At least in our family, Jack outranks Queen in Scopa but this is irrelevant for scoring purposes.



2: I've been playing this game since childhood and have never seen that happen but your code had better be able to handle that case!



3: There are bonus points for "sweeps" scored during the round which I am ignoring for the purpose of this challenge.










share|improve this question









$endgroup$




I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon.



The challenge: figure out the number of points scored in a round of Scopa, given the cards the player captured during the round as input.



There are 40 cards in a Scopa deck. If you are using an international deck you remove the 8s, 9s, and 10s, leaving A,2,3,4,5,6,7,Q,J,K in each suit.1 There are two players or partnerships, and after every round, all cards end up captured by one or the other of the two players. The score is counted as follows (more information here):



  • The player with the most cards scores 1 point.

  • The player with the most diamonds (or coins if using the Italian deck) scores 1 point.

  • The player with the 7 of diamonds (or coins), known as the sette bello or beautiful seven, scores 1 point.

  • The player with the highest primiera scores 1 point. A player's primiera score is the sum of the scores of the highest-value card that the player captured in each suit (see table below). If you do not have at least one card in every suit, you lose by default even if your score would exceed your opponent's score. In the exceedingly rare case that neither player has at least one card in every suit, the player with the higher primiera total scores the point.2

Table of primiera scores



| Rank | Value |
| ----- | ----- |
| 7 | 21 |
| 6 | 18 |
| A | 16 |
| 5 | 15 |
| 4 | 14 |
| 3 | 13 |
| 2 | 12 |
| Q,J,K | 10 |


So a player can score at most 4 points in a round.3 If there is a tie, which is possible for cards, diamonds, or primiera, no one scores the point.



It's important to realize that since each card must be captured by one of the two players, you can infer what cards the other player must have taken even if you only know what cards one player took. You will need to do this to correctly score primiera.



Challenge rules



Input



Your code should take as input the cards captured by a single player during a round of Scopa.



Input must be in string format, in which one character represents the rank of each card and one character its suit. This removes the potential loophole of passing the primiera scores in directly as input. Conversion of card ranks to primiera scores must be done in the program. However you may choose to use a single string separated by spaces or commas, an array of strings, or any other format. For example if you choose to encode ranks as 76A5432QJK and suits as DCHS you could use inputs such as ['7D', '6H', 'QD', 'JS'] or '7D,6H,QD,JS'.



Output



An integer from 0 to 4 representing the player's score.



Winning



Shortest answer in bytes wins!



Test cases



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "7C", "6C", "4C", "3C", "2C", "7H", "4H", "2H", "5S", "3S", "QS", "JS", "KS"]



Scores 4: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for the 7 of diamonds, and 1 point for scoring 78 in primiera (7,7,7,5 where opponent has 7,6,6,6 for 75)



["3D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "QC", "4H", "7S"]



Scores 0: <=20 cards, <=5 diamonds, no 7 of diamonds, and only scores 69 in primiera (7,7,4,3 where opponent has 7,7,6,K for 70)



[7D", "6D", "AD", "5D", "4D", "3D", "2D", "7C", "6C", "AC", "5C", "4C", "3C", "2C", "7H", "6H", "AH", "5H", "4H", "3H", "2H"]



Scores 3: 1 point for >20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera would be 63 (7,7,7) and the opponent can only score 51 (7,Q,Q,Q) but since this hand has no spades it loses the point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH", "QS"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. The primiera only scores 51 (7,Q,Q,Q) and the opponent can score 63 (7,7,7) but since the opponent's hand has no diamonds this hand wins the primiera point by default.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "7C", "7H"]



Scores 3: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. Even though this hand has no spades, it still wins primiera by a score of 63 to 57 (7,7,7 versus 7,6,6) because the opponent's hand has no diamonds.



["7D", "6D", "AD", "5D", "4D", "3D", "2D", "QD", "JD", "KD", "QC", "QH"]



Scores 2: <=20 cards, 1 point for >5 diamonds, 1 point for 7 of diamonds. This hand has no spades, and opponent's hand has no diamonds. Opponent wins primiera by a score of 63 to 41 (7,7,7 versus 7,Q,Q).



[] (empty array)



Scores 0




1: At least in our family, Jack outranks Queen in Scopa but this is irrelevant for scoring purposes.



2: I've been playing this game since childhood and have never seen that happen but your code had better be able to handle that case!



3: There are bonus points for "sweeps" scored during the round which I am ignoring for the purpose of this challenge.







code-golf card-games






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









qdreadqdread

1845 bronze badges




1845 bronze badges














  • $begingroup$
    Does each rank have to be represented by a distinct character?
    $endgroup$
    – Doorknob
    8 hours ago










  • $begingroup$
    @Doorknob No not necessarily, but at least in the solution I am working on I found it necessary to have a unique character for each rank to get all the test cases right.
    $endgroup$
    – qdread
    8 hours ago
















  • $begingroup$
    Does each rank have to be represented by a distinct character?
    $endgroup$
    – Doorknob
    8 hours ago










  • $begingroup$
    @Doorknob No not necessarily, but at least in the solution I am working on I found it necessary to have a unique character for each rank to get all the test cases right.
    $endgroup$
    – qdread
    8 hours ago















$begingroup$
Does each rank have to be represented by a distinct character?
$endgroup$
– Doorknob
8 hours ago




$begingroup$
Does each rank have to be represented by a distinct character?
$endgroup$
– Doorknob
8 hours ago












$begingroup$
@Doorknob No not necessarily, but at least in the solution I am working on I found it necessary to have a unique character for each rank to get all the test cases right.
$endgroup$
– qdread
8 hours ago




$begingroup$
@Doorknob No not necessarily, but at least in the solution I am working on I found it necessary to have a unique character for each rank to get all the test cases right.
$endgroup$
– qdread
8 hours ago










5 Answers
5






active

oldest

votes


















2














$begingroup$

Ruby, 156 153 bytes





->a


Try it online!



->a # count how many are left


This uses ;865432000 to represent 76A5432QJK respectively, and suits are in lowercase. (The choice of characters is because subtracting 38 from each gives their primiera value, but we never actually do so because only the relative difference matters.)



We don't check whether either player is missing a suit because it is unnecessary -- since all cards are counted as 38 plus their actual value, if someone is missing a suit, the highest score they can get is (21+38)*3 = 177, which is less than (10+38)*3 + 21+38 = 203, the lowest score the other player can get. We cannot have the two players missing an unequal nonzero number of suits, because a player can only be missing 0, 1, or 2 suits, and if someone is missing 2 suits they have all the cards of the other 2 suits.






share|improve this answer











$endgroup$






















    0














    $begingroup$

    JavaScript (ES6), 171 bytes



    Takes input as a set.





    a=>(x=(g=o=>[..."CHSD"].map(s=>[..."JQK2345A67"].map((v,i)=>(S=o^a.has(v+s))?m="111345679"[++n,i]||12:0,n=m=0)|(T|=!n,t-=m),T=t=0)|t*(T||99))``,a.size>20)+S+(n>5)+(x<g(1))


    Try it online!






    share|improve this answer









    $endgroup$






















      0














      $begingroup$


      Retina 0.8.2, 334 bytes



      $
      ¶234567JQKA
      r`.G
      $&C $&D $&H $&S
      +`((ww).*¶.*)2
      $1
      T`67AJQK`8960
      %O$`(w)(w)
      $2$1
      m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
      $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5
      m`^(?=(9D))?...;
      $#1;
      (;(?!.*10).* 0.*;).*
      $1
      d[C-S]
      1$&
      19w
      21$*@
      d+(w )?
      $*@
      (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
      $#1$#5$#6$#7
      1


      Try it online! Link includes test cases. Explanation:



      $
      ¶234567JQKA
      r`.G
      $&C $&D $&H $&S


      Create a list of all 40 cards.



      +`((ww).*¶.*)2 
      $1


      Remove the cards the player holds.



      T`67AJQK`8960


      Replace each rank by its sort order, which is 9 for 7 and 10 less than its value for other cards.



      %O$`(w)(w)
      $2$1


      Sort the cards by suit and rank.



      m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
      $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5


      Count the number of cards in each suit and also capture the highest ranked card in each suit, capturing the highest diamond twice.



      m`^(?=(9D))?...;
      $#1;


      Check whether the highest diamond was the 7.



      (;(?!.*10).* 0.*;).*
      $1


      Delete all of the highest cards if one of the suits has no cards.



      d[C-S] 
      1$&
      19w
      21$*@
      d+(w )?
      $*@


      Convert the highest cards to their unary score and sum them together. Also convert the total number of cards and suit lengths to unary.



      (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
      $#1$#5$#6$#7


      Score points if the total, diamonds, or primiera, is higher.



      1


      Total the score.






      share|improve this answer









      $endgroup$






















        0














        $begingroup$


        Python 3, 249 bytes





        lambda a:sum([len(a)>20,'7D'in a,len([x for x in a if x[1]<'E'])>5,p(a)>p(x+y for x in'9876543210'for y in S-a)])
        p=lambda a:[all(x in''.join(a)for x in S),sum(max([[0,7,3,4,5,6,9,12,0,0][int(x[0])]for x in a if x[1]==y]+[-9])for y in S)]
        S='DcHS'


        Uses 1 for Ace, 0 for Queen, 9 for Jack and 8 for King. The sets are D (Diamond), c (Club), H (Heart) and S (Spade).



        Try it online!






        share|improve this answer









        $endgroup$






















          0














          $begingroup$

          R, 320 298 bytes



          edit: golfed down by aliasing some functions.



          I am terrible at this, so I'm sure someone can improve on this if they care to take the time.



          h=scan(,'');b=substr;z=length;r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)));s=match(b(h,2,2),c('D','C','H','S'));l=c(11,8,6:2,0);p=0;for(i in 1:4)m=r[s==i];d=l[min(m)]-l[!1:8%in%m][1];if(!is.na(d))p=p+d;u=table(s);x=max(u)==10;(z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


          with newlines:



          h=scan(,'')
          b=substr
          z=length
          r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
          s=match(b(h,2,2),c('D','C','H','S'))
          l=c(11,8,6:2,0)
          p=0
          for(i in 1:4)m=r[s==i]
          d=l[min(m)]-l[!1:8%in%m][1]
          if(!is.na(d))p=p+d
          u=table(s)
          x=max(u)==10
          (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


          explanation



          h=scan(,'')
          b=substr
          z=length
          r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
          s=match(b(h,2,2),c('D','C','H','S'))


          Takes user input as a character vector, where face cards are all F, aliases some functions, splits each element of the vector into its first and second character, and maps them to ranks and suits respectively.



          l=c(11,8,6:2,0)


          Lookup table for primiera, with 10 subtracted from each value to save bytes since all cards score at least 10.



          p=0
          for(i in 1:4)m=r[s==i]
          d=l[min(m)]-l[!1:8%in%m][1]
          if(!is.na(d))p=p+d


          Sets p=0 and loops through the four suits to calculate the score for each suit. First we call m=r[s==i] to find my cards, or the ranks held in suit i.



          Next we find our score for suit i with l[min(m)] and the opponent's with l[!1:8%in%m][1], finding the highest-scoring rank not in m. We take the difference d between them.



          We increment the variable p by d if d is an integer. If the input has no cards in suit i, d will have the value NA. In the end p>0 means the player has a higher score than the opponent, ignoring missing suits for now.



          u=table(s) tabulates the number of cards in each suit.



          x=max(u)==10 is whether the opponent is missing a suit (if the player holds at least 10 cards in one suit).



          (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


          The final line adds up logicals for each of the four points which R converts to an integer. (z(h)>20) is for cards, (sum(s==1)>5) is for diamonds, (2%in%(r+s)) is for the 7 of diamonds which I encoded as having rank and suit values of 1.



          The last term on the final line outputs a logical for primiera which accounts for all possible cases of either the player or opponent, or both, missing a suit. If z(u)==4 the player holds at least one card in each suit.






          share|improve this answer











          $endgroup$
















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "200"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193547%2fwhat-is-the-score-of-my-scopa-hand%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            $begingroup$

            Ruby, 156 153 bytes





            ->a


            Try it online!



            ->a # count how many are left


            This uses ;865432000 to represent 76A5432QJK respectively, and suits are in lowercase. (The choice of characters is because subtracting 38 from each gives their primiera value, but we never actually do so because only the relative difference matters.)



            We don't check whether either player is missing a suit because it is unnecessary -- since all cards are counted as 38 plus their actual value, if someone is missing a suit, the highest score they can get is (21+38)*3 = 177, which is less than (10+38)*3 + 21+38 = 203, the lowest score the other player can get. We cannot have the two players missing an unequal nonzero number of suits, because a player can only be missing 0, 1, or 2 suits, and if someone is missing 2 suits they have all the cards of the other 2 suits.






            share|improve this answer











            $endgroup$



















              2














              $begingroup$

              Ruby, 156 153 bytes





              ->a


              Try it online!



              ->a # count how many are left


              This uses ;865432000 to represent 76A5432QJK respectively, and suits are in lowercase. (The choice of characters is because subtracting 38 from each gives their primiera value, but we never actually do so because only the relative difference matters.)



              We don't check whether either player is missing a suit because it is unnecessary -- since all cards are counted as 38 plus their actual value, if someone is missing a suit, the highest score they can get is (21+38)*3 = 177, which is less than (10+38)*3 + 21+38 = 203, the lowest score the other player can get. We cannot have the two players missing an unequal nonzero number of suits, because a player can only be missing 0, 1, or 2 suits, and if someone is missing 2 suits they have all the cards of the other 2 suits.






              share|improve this answer











              $endgroup$

















                2














                2










                2







                $begingroup$

                Ruby, 156 153 bytes





                ->a


                Try it online!



                ->a # count how many are left


                This uses ;865432000 to represent 76A5432QJK respectively, and suits are in lowercase. (The choice of characters is because subtracting 38 from each gives their primiera value, but we never actually do so because only the relative difference matters.)



                We don't check whether either player is missing a suit because it is unnecessary -- since all cards are counted as 38 plus their actual value, if someone is missing a suit, the highest score they can get is (21+38)*3 = 177, which is less than (10+38)*3 + 21+38 = 203, the lowest score the other player can get. We cannot have the two players missing an unequal nonzero number of suits, because a player can only be missing 0, 1, or 2 suits, and if someone is missing 2 suits they have all the cards of the other 2 suits.






                share|improve this answer











                $endgroup$



                Ruby, 156 153 bytes





                ->a


                Try it online!



                ->a # count how many are left


                This uses ;865432000 to represent 76A5432QJK respectively, and suits are in lowercase. (The choice of characters is because subtracting 38 from each gives their primiera value, but we never actually do so because only the relative difference matters.)



                We don't check whether either player is missing a suit because it is unnecessary -- since all cards are counted as 38 plus their actual value, if someone is missing a suit, the highest score they can get is (21+38)*3 = 177, which is less than (10+38)*3 + 21+38 = 203, the lowest score the other player can get. We cannot have the two players missing an unequal nonzero number of suits, because a player can only be missing 0, 1, or 2 suits, and if someone is missing 2 suits they have all the cards of the other 2 suits.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 7 hours ago









                DoorknobDoorknob

                56.3k17 gold badges121 silver badges362 bronze badges




                56.3k17 gold badges121 silver badges362 bronze badges


























                    0














                    $begingroup$

                    JavaScript (ES6), 171 bytes



                    Takes input as a set.





                    a=>(x=(g=o=>[..."CHSD"].map(s=>[..."JQK2345A67"].map((v,i)=>(S=o^a.has(v+s))?m="111345679"[++n,i]||12:0,n=m=0)|(T|=!n,t-=m),T=t=0)|t*(T||99))``,a.size>20)+S+(n>5)+(x<g(1))


                    Try it online!






                    share|improve this answer









                    $endgroup$



















                      0














                      $begingroup$

                      JavaScript (ES6), 171 bytes



                      Takes input as a set.





                      a=>(x=(g=o=>[..."CHSD"].map(s=>[..."JQK2345A67"].map((v,i)=>(S=o^a.has(v+s))?m="111345679"[++n,i]||12:0,n=m=0)|(T|=!n,t-=m),T=t=0)|t*(T||99))``,a.size>20)+S+(n>5)+(x<g(1))


                      Try it online!






                      share|improve this answer









                      $endgroup$

















                        0














                        0










                        0







                        $begingroup$

                        JavaScript (ES6), 171 bytes



                        Takes input as a set.





                        a=>(x=(g=o=>[..."CHSD"].map(s=>[..."JQK2345A67"].map((v,i)=>(S=o^a.has(v+s))?m="111345679"[++n,i]||12:0,n=m=0)|(T|=!n,t-=m),T=t=0)|t*(T||99))``,a.size>20)+S+(n>5)+(x<g(1))


                        Try it online!






                        share|improve this answer









                        $endgroup$



                        JavaScript (ES6), 171 bytes



                        Takes input as a set.





                        a=>(x=(g=o=>[..."CHSD"].map(s=>[..."JQK2345A67"].map((v,i)=>(S=o^a.has(v+s))?m="111345679"[++n,i]||12:0,n=m=0)|(T|=!n,t-=m),T=t=0)|t*(T||99))``,a.size>20)+S+(n>5)+(x<g(1))


                        Try it online!







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 5 hours ago









                        ArnauldArnauld

                        93.4k7 gold badges110 silver badges380 bronze badges




                        93.4k7 gold badges110 silver badges380 bronze badges
























                            0














                            $begingroup$


                            Retina 0.8.2, 334 bytes



                            $
                            ¶234567JQKA
                            r`.G
                            $&C $&D $&H $&S
                            +`((ww).*¶.*)2
                            $1
                            T`67AJQK`8960
                            %O$`(w)(w)
                            $2$1
                            m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                            $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5
                            m`^(?=(9D))?...;
                            $#1;
                            (;(?!.*10).* 0.*;).*
                            $1
                            d[C-S]
                            1$&
                            19w
                            21$*@
                            d+(w )?
                            $*@
                            (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                            $#1$#5$#6$#7
                            1


                            Try it online! Link includes test cases. Explanation:



                            $
                            ¶234567JQKA
                            r`.G
                            $&C $&D $&H $&S


                            Create a list of all 40 cards.



                            +`((ww).*¶.*)2 
                            $1


                            Remove the cards the player holds.



                            T`67AJQK`8960


                            Replace each rank by its sort order, which is 9 for 7 and 10 less than its value for other cards.



                            %O$`(w)(w)
                            $2$1


                            Sort the cards by suit and rank.



                            m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                            $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5


                            Count the number of cards in each suit and also capture the highest ranked card in each suit, capturing the highest diamond twice.



                            m`^(?=(9D))?...;
                            $#1;


                            Check whether the highest diamond was the 7.



                            (;(?!.*10).* 0.*;).*
                            $1


                            Delete all of the highest cards if one of the suits has no cards.



                            d[C-S] 
                            1$&
                            19w
                            21$*@
                            d+(w )?
                            $*@


                            Convert the highest cards to their unary score and sum them together. Also convert the total number of cards and suit lengths to unary.



                            (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                            $#1$#5$#6$#7


                            Score points if the total, diamonds, or primiera, is higher.



                            1


                            Total the score.






                            share|improve this answer









                            $endgroup$



















                              0














                              $begingroup$


                              Retina 0.8.2, 334 bytes



                              $
                              ¶234567JQKA
                              r`.G
                              $&C $&D $&H $&S
                              +`((ww).*¶.*)2
                              $1
                              T`67AJQK`8960
                              %O$`(w)(w)
                              $2$1
                              m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                              $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5
                              m`^(?=(9D))?...;
                              $#1;
                              (;(?!.*10).* 0.*;).*
                              $1
                              d[C-S]
                              1$&
                              19w
                              21$*@
                              d+(w )?
                              $*@
                              (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                              $#1$#5$#6$#7
                              1


                              Try it online! Link includes test cases. Explanation:



                              $
                              ¶234567JQKA
                              r`.G
                              $&C $&D $&H $&S


                              Create a list of all 40 cards.



                              +`((ww).*¶.*)2 
                              $1


                              Remove the cards the player holds.



                              T`67AJQK`8960


                              Replace each rank by its sort order, which is 9 for 7 and 10 less than its value for other cards.



                              %O$`(w)(w)
                              $2$1


                              Sort the cards by suit and rank.



                              m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                              $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5


                              Count the number of cards in each suit and also capture the highest ranked card in each suit, capturing the highest diamond twice.



                              m`^(?=(9D))?...;
                              $#1;


                              Check whether the highest diamond was the 7.



                              (;(?!.*10).* 0.*;).*
                              $1


                              Delete all of the highest cards if one of the suits has no cards.



                              d[C-S] 
                              1$&
                              19w
                              21$*@
                              d+(w )?
                              $*@


                              Convert the highest cards to their unary score and sum them together. Also convert the total number of cards and suit lengths to unary.



                              (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                              $#1$#5$#6$#7


                              Score points if the total, diamonds, or primiera, is higher.



                              1


                              Total the score.






                              share|improve this answer









                              $endgroup$

















                                0














                                0










                                0







                                $begingroup$


                                Retina 0.8.2, 334 bytes



                                $
                                ¶234567JQKA
                                r`.G
                                $&C $&D $&H $&S
                                +`((ww).*¶.*)2
                                $1
                                T`67AJQK`8960
                                %O$`(w)(w)
                                $2$1
                                m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                                $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5
                                m`^(?=(9D))?...;
                                $#1;
                                (;(?!.*10).* 0.*;).*
                                $1
                                d[C-S]
                                1$&
                                19w
                                21$*@
                                d+(w )?
                                $*@
                                (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                                $#1$#5$#6$#7
                                1


                                Try it online! Link includes test cases. Explanation:



                                $
                                ¶234567JQKA
                                r`.G
                                $&C $&D $&H $&S


                                Create a list of all 40 cards.



                                +`((ww).*¶.*)2 
                                $1


                                Remove the cards the player holds.



                                T`67AJQK`8960


                                Replace each rank by its sort order, which is 9 for 7 and 10 less than its value for other cards.



                                %O$`(w)(w)
                                $2$1


                                Sort the cards by suit and rank.



                                m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                                $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5


                                Count the number of cards in each suit and also capture the highest ranked card in each suit, capturing the highest diamond twice.



                                m`^(?=(9D))?...;
                                $#1;


                                Check whether the highest diamond was the 7.



                                (;(?!.*10).* 0.*;).*
                                $1


                                Delete all of the highest cards if one of the suits has no cards.



                                d[C-S] 
                                1$&
                                19w
                                21$*@
                                d+(w )?
                                $*@


                                Convert the highest cards to their unary score and sum them together. Also convert the total number of cards and suit lengths to unary.



                                (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                                $#1$#5$#6$#7


                                Score points if the total, diamonds, or primiera, is higher.



                                1


                                Total the score.






                                share|improve this answer









                                $endgroup$




                                Retina 0.8.2, 334 bytes



                                $
                                ¶234567JQKA
                                r`.G
                                $&C $&D $&H $&S
                                +`((ww).*¶.*)2
                                $1
                                T`67AJQK`8960
                                %O$`(w)(w)
                                $2$1
                                m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                                $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5
                                m`^(?=(9D))?...;
                                $#1;
                                (;(?!.*10).* 0.*;).*
                                $1
                                d[C-S]
                                1$&
                                19w
                                21$*@
                                d+(w )?
                                $*@
                                (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                                $#1$#5$#6$#7
                                1


                                Try it online! Link includes test cases. Explanation:



                                $
                                ¶234567JQKA
                                r`.G
                                $&C $&D $&H $&S


                                Create a list of all 40 cards.



                                +`((ww).*¶.*)2 
                                $1


                                Remove the cards the player holds.



                                T`67AJQK`8960


                                Replace each rank by its sort order, which is 9 for 7 and 10 less than its value for other cards.



                                %O$`(w)(w)
                                $2$1


                                Sort the cards by suit and rank.



                                m`^(?=(...)*)(.C )*(.D )*(.H )*(.S )*
                                $3;$#1 $#2 $#3 $#4 $#5;$2$3$4$5


                                Count the number of cards in each suit and also capture the highest ranked card in each suit, capturing the highest diamond twice.



                                m`^(?=(9D))?...;
                                $#1;


                                Check whether the highest diamond was the 7.



                                (;(?!.*10).* 0.*;).*
                                $1


                                Delete all of the highest cards if one of the suits has no cards.



                                d[C-S] 
                                1$&
                                19w
                                21$*@
                                d+(w )?
                                $*@


                                Convert the highest cards to their unary score and sum them together. Also convert the total number of cards and suit lengths to unary.



                                (@)?;(@*) @* (@*).*;(@*)¶@?;((?!2))?@* @* ((?!3))?.*;((?!4))?.*
                                $#1$#5$#6$#7


                                Score points if the total, diamonds, or primiera, is higher.



                                1


                                Total the score.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 4 hours ago









                                NeilNeil

                                89.3k8 gold badges46 silver badges188 bronze badges




                                89.3k8 gold badges46 silver badges188 bronze badges
























                                    0














                                    $begingroup$


                                    Python 3, 249 bytes





                                    lambda a:sum([len(a)>20,'7D'in a,len([x for x in a if x[1]<'E'])>5,p(a)>p(x+y for x in'9876543210'for y in S-a)])
                                    p=lambda a:[all(x in''.join(a)for x in S),sum(max([[0,7,3,4,5,6,9,12,0,0][int(x[0])]for x in a if x[1]==y]+[-9])for y in S)]
                                    S='DcHS'


                                    Uses 1 for Ace, 0 for Queen, 9 for Jack and 8 for King. The sets are D (Diamond), c (Club), H (Heart) and S (Spade).



                                    Try it online!






                                    share|improve this answer









                                    $endgroup$



















                                      0














                                      $begingroup$


                                      Python 3, 249 bytes





                                      lambda a:sum([len(a)>20,'7D'in a,len([x for x in a if x[1]<'E'])>5,p(a)>p(x+y for x in'9876543210'for y in S-a)])
                                      p=lambda a:[all(x in''.join(a)for x in S),sum(max([[0,7,3,4,5,6,9,12,0,0][int(x[0])]for x in a if x[1]==y]+[-9])for y in S)]
                                      S='DcHS'


                                      Uses 1 for Ace, 0 for Queen, 9 for Jack and 8 for King. The sets are D (Diamond), c (Club), H (Heart) and S (Spade).



                                      Try it online!






                                      share|improve this answer









                                      $endgroup$

















                                        0














                                        0










                                        0







                                        $begingroup$


                                        Python 3, 249 bytes





                                        lambda a:sum([len(a)>20,'7D'in a,len([x for x in a if x[1]<'E'])>5,p(a)>p(x+y for x in'9876543210'for y in S-a)])
                                        p=lambda a:[all(x in''.join(a)for x in S),sum(max([[0,7,3,4,5,6,9,12,0,0][int(x[0])]for x in a if x[1]==y]+[-9])for y in S)]
                                        S='DcHS'


                                        Uses 1 for Ace, 0 for Queen, 9 for Jack and 8 for King. The sets are D (Diamond), c (Club), H (Heart) and S (Spade).



                                        Try it online!






                                        share|improve this answer









                                        $endgroup$




                                        Python 3, 249 bytes





                                        lambda a:sum([len(a)>20,'7D'in a,len([x for x in a if x[1]<'E'])>5,p(a)>p(x+y for x in'9876543210'for y in S-a)])
                                        p=lambda a:[all(x in''.join(a)for x in S),sum(max([[0,7,3,4,5,6,9,12,0,0][int(x[0])]for x in a if x[1]==y]+[-9])for y in S)]
                                        S='DcHS'


                                        Uses 1 for Ace, 0 for Queen, 9 for Jack and 8 for King. The sets are D (Diamond), c (Club), H (Heart) and S (Spade).



                                        Try it online!







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 3 hours ago









                                        Black Owl KaiBlack Owl Kai

                                        8001 silver badge12 bronze badges




                                        8001 silver badge12 bronze badges
























                                            0














                                            $begingroup$

                                            R, 320 298 bytes



                                            edit: golfed down by aliasing some functions.



                                            I am terrible at this, so I'm sure someone can improve on this if they care to take the time.



                                            h=scan(,'');b=substr;z=length;r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)));s=match(b(h,2,2),c('D','C','H','S'));l=c(11,8,6:2,0);p=0;for(i in 1:4)m=r[s==i];d=l[min(m)]-l[!1:8%in%m][1];if(!is.na(d))p=p+d;u=table(s);x=max(u)==10;(z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                            with newlines:



                                            h=scan(,'')
                                            b=substr
                                            z=length
                                            r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                            s=match(b(h,2,2),c('D','C','H','S'))
                                            l=c(11,8,6:2,0)
                                            p=0
                                            for(i in 1:4)m=r[s==i]
                                            d=l[min(m)]-l[!1:8%in%m][1]
                                            if(!is.na(d))p=p+d
                                            u=table(s)
                                            x=max(u)==10
                                            (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                            explanation



                                            h=scan(,'')
                                            b=substr
                                            z=length
                                            r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                            s=match(b(h,2,2),c('D','C','H','S'))


                                            Takes user input as a character vector, where face cards are all F, aliases some functions, splits each element of the vector into its first and second character, and maps them to ranks and suits respectively.



                                            l=c(11,8,6:2,0)


                                            Lookup table for primiera, with 10 subtracted from each value to save bytes since all cards score at least 10.



                                            p=0
                                            for(i in 1:4)m=r[s==i]
                                            d=l[min(m)]-l[!1:8%in%m][1]
                                            if(!is.na(d))p=p+d


                                            Sets p=0 and loops through the four suits to calculate the score for each suit. First we call m=r[s==i] to find my cards, or the ranks held in suit i.



                                            Next we find our score for suit i with l[min(m)] and the opponent's with l[!1:8%in%m][1], finding the highest-scoring rank not in m. We take the difference d between them.



                                            We increment the variable p by d if d is an integer. If the input has no cards in suit i, d will have the value NA. In the end p>0 means the player has a higher score than the opponent, ignoring missing suits for now.



                                            u=table(s) tabulates the number of cards in each suit.



                                            x=max(u)==10 is whether the opponent is missing a suit (if the player holds at least 10 cards in one suit).



                                            (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                            The final line adds up logicals for each of the four points which R converts to an integer. (z(h)>20) is for cards, (sum(s==1)>5) is for diamonds, (2%in%(r+s)) is for the 7 of diamonds which I encoded as having rank and suit values of 1.



                                            The last term on the final line outputs a logical for primiera which accounts for all possible cases of either the player or opponent, or both, missing a suit. If z(u)==4 the player holds at least one card in each suit.






                                            share|improve this answer











                                            $endgroup$



















                                              0














                                              $begingroup$

                                              R, 320 298 bytes



                                              edit: golfed down by aliasing some functions.



                                              I am terrible at this, so I'm sure someone can improve on this if they care to take the time.



                                              h=scan(,'');b=substr;z=length;r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)));s=match(b(h,2,2),c('D','C','H','S'));l=c(11,8,6:2,0);p=0;for(i in 1:4)m=r[s==i];d=l[min(m)]-l[!1:8%in%m][1];if(!is.na(d))p=p+d;u=table(s);x=max(u)==10;(z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                              with newlines:



                                              h=scan(,'')
                                              b=substr
                                              z=length
                                              r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                              s=match(b(h,2,2),c('D','C','H','S'))
                                              l=c(11,8,6:2,0)
                                              p=0
                                              for(i in 1:4)m=r[s==i]
                                              d=l[min(m)]-l[!1:8%in%m][1]
                                              if(!is.na(d))p=p+d
                                              u=table(s)
                                              x=max(u)==10
                                              (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                              explanation



                                              h=scan(,'')
                                              b=substr
                                              z=length
                                              r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                              s=match(b(h,2,2),c('D','C','H','S'))


                                              Takes user input as a character vector, where face cards are all F, aliases some functions, splits each element of the vector into its first and second character, and maps them to ranks and suits respectively.



                                              l=c(11,8,6:2,0)


                                              Lookup table for primiera, with 10 subtracted from each value to save bytes since all cards score at least 10.



                                              p=0
                                              for(i in 1:4)m=r[s==i]
                                              d=l[min(m)]-l[!1:8%in%m][1]
                                              if(!is.na(d))p=p+d


                                              Sets p=0 and loops through the four suits to calculate the score for each suit. First we call m=r[s==i] to find my cards, or the ranks held in suit i.



                                              Next we find our score for suit i with l[min(m)] and the opponent's with l[!1:8%in%m][1], finding the highest-scoring rank not in m. We take the difference d between them.



                                              We increment the variable p by d if d is an integer. If the input has no cards in suit i, d will have the value NA. In the end p>0 means the player has a higher score than the opponent, ignoring missing suits for now.



                                              u=table(s) tabulates the number of cards in each suit.



                                              x=max(u)==10 is whether the opponent is missing a suit (if the player holds at least 10 cards in one suit).



                                              (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                              The final line adds up logicals for each of the four points which R converts to an integer. (z(h)>20) is for cards, (sum(s==1)>5) is for diamonds, (2%in%(r+s)) is for the 7 of diamonds which I encoded as having rank and suit values of 1.



                                              The last term on the final line outputs a logical for primiera which accounts for all possible cases of either the player or opponent, or both, missing a suit. If z(u)==4 the player holds at least one card in each suit.






                                              share|improve this answer











                                              $endgroup$

















                                                0














                                                0










                                                0







                                                $begingroup$

                                                R, 320 298 bytes



                                                edit: golfed down by aliasing some functions.



                                                I am terrible at this, so I'm sure someone can improve on this if they care to take the time.



                                                h=scan(,'');b=substr;z=length;r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)));s=match(b(h,2,2),c('D','C','H','S'));l=c(11,8,6:2,0);p=0;for(i in 1:4)m=r[s==i];d=l[min(m)]-l[!1:8%in%m][1];if(!is.na(d))p=p+d;u=table(s);x=max(u)==10;(z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                                with newlines:



                                                h=scan(,'')
                                                b=substr
                                                z=length
                                                r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                                s=match(b(h,2,2),c('D','C','H','S'))
                                                l=c(11,8,6:2,0)
                                                p=0
                                                for(i in 1:4)m=r[s==i]
                                                d=l[min(m)]-l[!1:8%in%m][1]
                                                if(!is.na(d))p=p+d
                                                u=table(s)
                                                x=max(u)==10
                                                (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                                explanation



                                                h=scan(,'')
                                                b=substr
                                                z=length
                                                r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                                s=match(b(h,2,2),c('D','C','H','S'))


                                                Takes user input as a character vector, where face cards are all F, aliases some functions, splits each element of the vector into its first and second character, and maps them to ranks and suits respectively.



                                                l=c(11,8,6:2,0)


                                                Lookup table for primiera, with 10 subtracted from each value to save bytes since all cards score at least 10.



                                                p=0
                                                for(i in 1:4)m=r[s==i]
                                                d=l[min(m)]-l[!1:8%in%m][1]
                                                if(!is.na(d))p=p+d


                                                Sets p=0 and loops through the four suits to calculate the score for each suit. First we call m=r[s==i] to find my cards, or the ranks held in suit i.



                                                Next we find our score for suit i with l[min(m)] and the opponent's with l[!1:8%in%m][1], finding the highest-scoring rank not in m. We take the difference d between them.



                                                We increment the variable p by d if d is an integer. If the input has no cards in suit i, d will have the value NA. In the end p>0 means the player has a higher score than the opponent, ignoring missing suits for now.



                                                u=table(s) tabulates the number of cards in each suit.



                                                x=max(u)==10 is whether the opponent is missing a suit (if the player holds at least 10 cards in one suit).



                                                (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                                The final line adds up logicals for each of the four points which R converts to an integer. (z(h)>20) is for cards, (sum(s==1)>5) is for diamonds, (2%in%(r+s)) is for the 7 of diamonds which I encoded as having rank and suit values of 1.



                                                The last term on the final line outputs a logical for primiera which accounts for all possible cases of either the player or opponent, or both, missing a suit. If z(u)==4 the player holds at least one card in each suit.






                                                share|improve this answer











                                                $endgroup$



                                                R, 320 298 bytes



                                                edit: golfed down by aliasing some functions.



                                                I am terrible at this, so I'm sure someone can improve on this if they care to take the time.



                                                h=scan(,'');b=substr;z=length;r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)));s=match(b(h,2,2),c('D','C','H','S'));l=c(11,8,6:2,0);p=0;for(i in 1:4)m=r[s==i];d=l[min(m)]-l[!1:8%in%m][1];if(!is.na(d))p=p+d;u=table(s);x=max(u)==10;(z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                                with newlines:



                                                h=scan(,'')
                                                b=substr
                                                z=length
                                                r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                                s=match(b(h,2,2),c('D','C','H','S'))
                                                l=c(11,8,6:2,0)
                                                p=0
                                                for(i in 1:4)m=r[s==i]
                                                d=l[min(m)]-l[!1:8%in%m][1]
                                                if(!is.na(d))p=p+d
                                                u=table(s)
                                                x=max(u)==10
                                                (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                                explanation



                                                h=scan(,'')
                                                b=substr
                                                z=length
                                                r=match(b(h,1,1),c(7:6,'A',5:2,rep('F',3)))
                                                s=match(b(h,2,2),c('D','C','H','S'))


                                                Takes user input as a character vector, where face cards are all F, aliases some functions, splits each element of the vector into its first and second character, and maps them to ranks and suits respectively.



                                                l=c(11,8,6:2,0)


                                                Lookup table for primiera, with 10 subtracted from each value to save bytes since all cards score at least 10.



                                                p=0
                                                for(i in 1:4)m=r[s==i]
                                                d=l[min(m)]-l[!1:8%in%m][1]
                                                if(!is.na(d))p=p+d


                                                Sets p=0 and loops through the four suits to calculate the score for each suit. First we call m=r[s==i] to find my cards, or the ranks held in suit i.



                                                Next we find our score for suit i with l[min(m)] and the opponent's with l[!1:8%in%m][1], finding the highest-scoring rank not in m. We take the difference d between them.



                                                We increment the variable p by d if d is an integer. If the input has no cards in suit i, d will have the value NA. In the end p>0 means the player has a higher score than the opponent, ignoring missing suits for now.



                                                u=table(s) tabulates the number of cards in each suit.



                                                x=max(u)==10 is whether the opponent is missing a suit (if the player holds at least 10 cards in one suit).



                                                (z(h)>20)+(sum(s==1)>5)+(2%in%(r+s))+((z(u)==4&(p>0|x))|(z(u)<4&x&p>0))


                                                The final line adds up logicals for each of the four points which R converts to an integer. (z(h)>20) is for cards, (sum(s==1)>5) is for diamonds, (2%in%(r+s)) is for the 7 of diamonds which I encoded as having rank and suit values of 1.



                                                The last term on the final line outputs a logical for primiera which accounts for all possible cases of either the player or opponent, or both, missing a suit. If z(u)==4 the player holds at least one card in each suit.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 1 hour ago

























                                                answered 8 hours ago









                                                qdreadqdread

                                                1845 bronze badges




                                                1845 bronze badges































                                                    draft saved

                                                    draft discarded















































                                                    If this is an answer to a challenge…



                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                    More generally…



                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193547%2fwhat-is-the-score-of-my-scopa-hand%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                                    Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367