Retired

Spades Problem (retired)

Description:

In the game of spades, there are four players. The first dealer is chosen at random, and the turn to deal rotates clockwise. The cards are shuffled and the dealer deals all 52 cards to the other three players in clockwise order beginning with the player on dealer's left until everyone has 13 cards in their hands.

The first round of the game is for each player to lay down their lowest club, where clubs are ordered from low to high as: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.

Once all four lowest clubs are on the table, the player who threw the highest of those four cards wins the cards (i.e. that player wins the "trick"). If a player has no clubs, he or she must discard a diamond or a heart, and that card has no chance of winning the trick. If a player has no clubs, no hearts, and no diamonds, then the player must play a spade, and will be guaranteed to win the trick.

Given a card given in the format "2H" , where "2" is the value and "H" stands for hearts which is the suit, compute for the winning probability of that card. Results must contain two significant digits after the decimal.

Note: Tolerance is 4e-2

Sample Input Sample Output
2C 0
10C 9.08
KC 3.49
9C 11.87
2S 0
AH 0
Algorithms
Mathematics
Logic
Numbers
Data Types
Games

More By Author:

Check out these other kata created by raff_ralo

Stats:

CreatedJun 25, 2019
Warriors Trained21
Total Skips0
Total Code Submissions25
Total Times Completed6
Java Completions6
Total Stars2
% of votes with a positive feedback rating0% of 4
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes4
Total Rank Assessments4
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • raff_ralo Avatar
Ad