浏览代码

Change indentation and correct mistakes

katmpatz 6 年前
父节点
当前提交
5e1e6f1e15

+ 4
- 5
exercises/poker/.meta/src/reference/java/Card.java 查看文件

@@ -17,13 +17,12 @@ class Card {
17 17
 
18 18
     private int parseRank(String card) {
19 19
     	if (card.substring(0, 2).equals("10")) {
20
-			return 10;
21
-		}
22
-		String s = "..23456789TJQKA";
23
-		return s.indexOf(card.charAt(0));
20
+    		return 10;
21
+    	}
22
+    	return "..23456789TJQKA".indexOf(card.charAt(0));
24 23
     }
25 24
 
26 25
     private int parseSuit(String card) {
27
-        return ".HSDC".indexOf(card.charAt(card.length()-1));
26
+        return ".HSDC".indexOf(card.charAt(card.length() - 1));
28 27
     }
29 28
 }

+ 138
- 115
exercises/poker/.meta/src/reference/java/Hand.java 查看文件

@@ -2,129 +2,152 @@ import java.util.*;
2 2
 import java.util.stream.Collectors;
3 3
 
4 4
 class Hand {
5
-	private String input;
6
-	private int score;
5
+    private String input;
6
+    private int score;
7 7
 
8
-	Hand(String hand) {
9
-		this.input = hand;
10
-		this.score = scoreHand(parseCards(hand));
11
-	}
8
+    Hand(String hand) {
9
+        this.input = hand;
10
+        this.score = scoreHand(parseCards(hand));
11
+    }
12 12
 
13
-	int getScore() {
14
-		return score;
15
-	}
13
+    int getScore() {
14
+        return score;
15
+    }
16 16
 
17
-	String getInput() {
18
-		return input;
19
-	}
17
+    String getInput() {
18
+        return input;
19
+    }
20 20
 
21
-	private List<Card> parseCards(String hand) {
22
-		ArrayList<Card> parsedCards = new ArrayList<>();
23
-		String[] cardsToParse = hand.split(" ");
24
-		for (String cardToParse : cardsToParse) {
25
-			parsedCards.add(new Card(cardToParse));
26
-		}
27
-		return parsedCards;
28
-	}
21
+    private List<Card> parseCards(String hand) {
22
+        ArrayList<Card> parsedCards = new ArrayList<>();
23
+        String[] cardsToParse = hand.split(" ");
24
+        for (String cardToParse : cardsToParse) {
25
+            parsedCards.add(new Card(cardToParse));
26
+        }
27
+        return parsedCards;
28
+    }
29 29
 
30
-	private Map<Integer, Integer> getFrequencyMap(List<Card> cards) {
31
-		Map<Integer, Integer> frequencyMap = new HashMap<>();
32
-		for (Card c : cards) {
33
-			if (frequencyMap.containsKey(c.getRank())) {
34
-				frequencyMap.put(c.getRank(), frequencyMap.get(c.getRank()) + 1);
35
-			} else {
36
-				frequencyMap.put(c.getRank(), 1);
37
-			}
38
-		}
39
-		return frequencyMap;
40
-	}
30
+    private Map<Integer, Integer> getFrequencyMap(List<Card> cards) {
31
+        Map<Integer, Integer> frequencyMap = new HashMap<>();
32
+        for (Card c : cards) {
33
+            if (frequencyMap.containsKey(c.getRank())) {
34
+                frequencyMap.put(c.getRank(), frequencyMap.get(c.getRank()) + 1);
35
+            } else {
36
+                    frequencyMap.put(c.getRank(), 1);
37
+            }
38
+        }
39
+        return frequencyMap;
40
+    }
41
+    
42
+    private int scoreHand(List<Card> cards) {
43
+        List<Card> cardsByRank = cards.stream()
44
+                .sorted(Comparator.comparing(Card::getRank))
45
+                .unordered()
46
+                .collect(Collectors.toList());
41 47
 
42
-	private int scoreHand(List<Card> cards) {
43
-		List<Card> cardsByRank = cards.stream().sorted(Comparator.comparing(Card::getRank)).unordered()
44
-				.collect(Collectors.toList());
48
+        Map<Integer, Integer> frequencyMap = getFrequencyMap(cards);
49
+        List<Integer> ranks = frequencyMap
50
+                .entrySet()
51
+                .stream()
52
+                .map(Map.Entry::getKey)
53
+                .sorted(Comparator.reverseOrder())
54
+                .collect(Collectors.toList());
55
+        frequencyMap = frequencyMap
56
+                .entrySet()
57
+                .stream()
58
+                .sorted(Map.Entry.comparingByValue(Collections.reverseOrder()))
59
+                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
60
+        List<Integer> rankCounts = frequencyMap
61
+                .entrySet()
62
+                .stream()
63
+                .map(Map.Entry::getValue)
64
+                .collect(Collectors.toList());
65
+        List<Integer> suits = cards
66
+                .stream()
67
+                .map(Card::getSuit)
68
+                .collect(Collectors.toList());
45 69
 
46
-		Map<Integer, Integer> frequencyMap = getFrequencyMap(cards);
47
-		List<Integer> ranks = frequencyMap.entrySet().stream().map(Map.Entry::getKey).sorted(Comparator.reverseOrder())
48
-				.collect(Collectors.toList());
49
-		frequencyMap = frequencyMap.entrySet().stream().sorted(Map.Entry.comparingByValue(Collections.reverseOrder()))
50
-				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
51
-		List<Integer> rankCounts = frequencyMap.entrySet().stream().map(Map.Entry::getValue)
52
-				.collect(Collectors.toList());
53
-		List<Integer> suits = cards.stream().map(Card::getSuit).collect(Collectors.toList());
70
+        return calculatedScore(frequencyMap, cardsByRank, ranks, rankCounts, suits);
71
+    }
54 72
 
55
-		return calculatedScore(frequencyMap, cardsByRank, ranks, rankCounts, suits);
56
-	}
73
+    private int calculatedScore(Map<Integer, Integer> frequencyMap, List<Card> cardsByRank, List<Integer> ranks,
74
+                                List<Integer> rankCounts, List<Integer> suits) {
75
+        if (ranks.equals(Arrays.asList(14, 5, 4, 3, 2))) {
76
+            ranks = Arrays.asList(5, 4, 3, 2, 1);
77
+        }
57 78
 
58
-	private int calculatedScore(Map<Integer, Integer> frequencyMap, List<Card> cardsByRank, List<Integer> ranks,
59
-			List<Integer> rankCounts, List<Integer> suits) {
60
-		if (ranks.equals(Arrays.asList(14, 5, 4, 3, 2))) {
61
-			ranks = Arrays.asList(5, 4, 3, 2, 1);
62
-		}
79
+        boolean flush = suits
80
+                .stream()
81
+                .distinct()
82
+                .count() == 1;
83
+        boolean straight = ranks
84
+                .stream()
85
+                .distinct()
86
+                .count() == 5 && ranks
87
+                .get(0) - ranks
88
+                .get(4) == 4;
89
+        
90
+        Iterator<Integer> iteratorOverFrequencies = frequencyMap.keySet().iterator();
91
+        
92
+        int highestFrequency = iteratorOverFrequencies.next();
63 93
 
64
-		boolean flush = suits.stream().distinct().count() == 1;
65
-		boolean straight = ranks.stream().distinct().count() == 5 && ranks.get(0) - ranks.get(4) == 4;
66
-		Iterator<Integer> iteratorOverFrequencies = frequencyMap.keySet().iterator();
67
-		int highestFrequency = iteratorOverFrequencies.next();
94
+        int maxValue = Collections.max(ranks);
68 95
 
69
-		int maxValue = Collections.max(ranks);
70
-
71
-		if (straight && flush) {
72
-			return 800 + highestFrequency;
73
-		}
74
-		if (rankCounts.equals(Arrays.asList(4, 1))) {
75
-			return 700 + cardsByRank.get(0).getRank();
76
-		}
77
-		if (rankCounts.equals(Arrays.asList(3, 2))) {
78
-			int triplet = 0;
79
-			int pair = 0;
80
-			for (Object key : frequencyMap.keySet()) {
81
-				if (frequencyMap.get(key) == 2) {
82
-					pair = (int) key;
83
-				}
84
-				if (frequencyMap.get(key) == 3) {
85
-					triplet = 3 * (int) key;
86
-				}
87
-			}
88
-			return 600 + 3 * triplet + pair;
89
-		}
90
-		if (flush) {
91
-			return 500 + highestFrequency;
92
-		}
93
-		if (straight) {
94
-			return 400 + maxValue;
95
-		}
96
-		if (rankCounts.equals(Arrays.asList(3, 1, 1))) {
97
-			List<Integer> cardsf1 = new ArrayList<Integer>();
98
-			int triplet = 0;
99
-			for (Object key : frequencyMap.keySet()) {
100
-				if (frequencyMap.get(key) == 1) {
101
-					cardsf1.add((int) key);
102
-				}
103
-				if (frequencyMap.get(key) == 3) {
104
-					triplet = 3 * (int) key;
105
-				}
106
-			}
107
-
108
-			return 300 + triplet + Collections.max(cardsf1);
109
-		}
110
-		if (rankCounts.equals(Arrays.asList(2, 2, 1))) {
111
-			int sum = 0;
112
-			for (Object key : frequencyMap.keySet()) {
113
-				int fKey = (int) key;
114
-				int fValue = frequencyMap.get(key);
115
-				sum += fKey * fValue;
116
-			}
117
-			return 200 + sum + 2 * Math.max(highestFrequency, iteratorOverFrequencies.next());
118
-		}
119
-		if (rankCounts.equals(Arrays.asList(2, 1, 1, 1))) {
120
-			return 100 + highestFrequency;
121
-		}
122
-		ranks.sort(Comparator.naturalOrder());
123
-		int result = 0;
124
-		for (int i = 0; i < ranks.size(); i++) {
125
-			result += ranks.get(0) * (i + 1);
126
-		}
127
-		return result + ranks.get(ranks.size() - 1);
128
-	}
129
-
130
-}
96
+        if (straight && flush) {
97
+            return 800 + highestFrequency;
98
+        }
99
+        if (rankCounts.equals(Arrays.asList(4, 1))) {
100
+            return 700 + cardsByRank.get(0).getRank();
101
+        }
102
+        if (rankCounts.equals(Arrays.asList(3, 2))) {
103
+            int triplet = 0;
104
+            int pair = 0;
105
+            for (Integer key : frequencyMap.keySet()) {
106
+                if (frequencyMap.get(key) == 2) {
107
+                    pair = (int) key;
108
+                }
109
+                if (frequencyMap.get(key) == 3) {
110
+                    triplet = 3 * (int) key;
111
+                }
112
+            }
113
+            return 600 + 3 * triplet + pair;
114
+        }
115
+        if (flush) {
116
+            return 500 + highestFrequency;
117
+        }
118
+        if (straight) {
119
+            return 400 + maxValue;
120
+        }
121
+        if (rankCounts.equals(Arrays.asList(3, 1, 1))) {
122
+            List<Integer> unique_cards = new ArrayList<Integer>();
123
+            int triplet = 0;
124
+            for (Integer key : frequencyMap.keySet()) {
125
+                if (frequencyMap.get(key) == 1) {
126
+                    unique_cards.add((int) key);
127
+                }
128
+                if (frequencyMap.get(key) == 3) {
129
+                    triplet = 3 * (int) key;
130
+                }
131
+            }
132
+            return 300 + triplet + Collections.max(unique_cards);
133
+        }
134
+        if (rankCounts.equals(Arrays.asList(2, 2, 1))) {
135
+            int products_of_frequency_and_value = 0;
136
+            for (Integer key : frequencyMap.keySet()) {
137
+                int frequencyKey = (int) key;
138
+                int frequencyValue = frequencyMap.get(key);
139
+                products_of_frequency_and_value += frequencyKey * frequencyValue;
140
+            }
141
+            return 200 + products_of_frequency_and_value + 2 * Math.max(highestFrequency, iteratorOverFrequencies.next());
142
+        }
143
+        if (rankCounts.equals(Arrays.asList(2, 1, 1, 1))) {
144
+            return 100 + highestFrequency;
145
+        }
146
+        ranks.sort(Comparator.naturalOrder());
147
+        int result = 0;
148
+        for (int i = 0; i < ranks.size(); i++) {
149
+            result += ranks.get(0) * (i + 1);
150
+        }
151
+        return result + ranks.get(ranks.size() - 1);
152
+    }
153
+}               

+ 230
- 237
exercises/poker/src/test/java/PokerTest.java 查看文件

@@ -1,239 +1,232 @@
1
-import org.junit.Ignore;
2
-import org.junit.Test;
3
-
4
-import java.util.Arrays;
5
-
6
-import static org.junit.Assert.assertEquals;
7
-
8 1
 public class PokerTest {
9
-	@Test
10
-	public void oneHand() {
11
-		String hand = "4S 5S 7H 8D JC";
12
-		assertEquals(Arrays.asList(hand), new Poker(Arrays.asList(hand)).getBestHands());
13
-	}
14
-
15
-	@Ignore("Remove to run test")
16
-	@Test
17
-	public void highestCardWins() {
18
-		String highest8 = "4D 5S 6S 8D 3C";
19
-		String highest10 = "2S 4C 7S 9H 10H";
20
-		String highestJ = "3S 4S 5D 6H JH";
21
-		assertEquals(Arrays.asList(highestJ), new Poker(Arrays.asList(highest8, highest10, highestJ)).getBestHands());
22
-	}
23
-
24
-	@Ignore("Remove to run test")
25
-	@Test
26
-	public void tieHasMultipleWinners() {
27
-		String highest8 = "4D 5S 6S 8D 3C";
28
-		String highest10 = "2S 4C 7S 9H 10H";
29
-		String highestJh = "3S 4S 5D 6H JH";
30
-		String highestJd = "3H 4H 5C 6C JD";
31
-		assertEquals(Arrays.asList(highestJh, highestJd),
32
-				new Poker(Arrays.asList(highest8, highest10, highestJh, highestJd)).getBestHands());
33
-	}
34
-
35
-	@Ignore("Remove to run test")
36
-	@Test
37
-	public void sameHighCards() {
38
-		String nextHighest3 = "3S 5H 6S 8D 7H";
39
-		String nextHighest2 = "2S 5D 6D 8C 7S";
40
-		assertEquals(Arrays.asList(nextHighest3), new Poker(Arrays.asList(nextHighest3, nextHighest2)).getBestHands());
41
-	}
42
-
43
-	@Ignore("Remove to run test")
44
-	@Test
45
-	public void nothingVsOnePair() {
46
-		String nothing = "4S 5H 6C 8D KH";
47
-		String pairOf4 = "2S 4H 6S 4D JH";
48
-		assertEquals(Arrays.asList(pairOf4), new Poker(Arrays.asList(nothing, pairOf4)).getBestHands());
49
-	}
50
-
51
-	@Ignore("Remove to run test")
52
-	@Test
53
-	public void twoPairs() {
54
-		String pairOf2 = "4S 2H 6S 2D JH";
55
-		String pairOf4 = "2S 4H 6C 4D JD";
56
-		assertEquals(Arrays.asList(pairOf4), new Poker(Arrays.asList(pairOf2, pairOf4)).getBestHands());
57
-	}
58
-
59
-	@Ignore("Remove to run test")
60
-	@Test
61
-	public void onePairVsDoublePair() {
62
-		String pairOf8 = "2S 8H 6S 8D JH";
63
-		String doublePair = "4S 5H 4C 8C 5H";
64
-		assertEquals(Arrays.asList(doublePair), new Poker(Arrays.asList(pairOf8, doublePair)).getBestHands());
65
-	}
66
-
67
-	@Ignore("Remove to run test")
68
-	@Test
69
-	public void twoDoublePairs() {
70
-		String doublePair2And8 = "2S 8H 2D 8D 3H";
71
-		String doublePair4And5 = "4S 5H 4C 8S 5D";
72
-		assertEquals(Arrays.asList(doublePair2And8),
73
-				new Poker(Arrays.asList(doublePair2And8, doublePair4And5)).getBestHands());
74
-	}
75
-
76
-	@Ignore("Remove to run test")
77
-	@Test
78
-	public void sameHighestPair() {
79
-		String doublePair2AndQ = "2S QS 2C QD JH";
80
-		String doublePairJAndQ = "JD QH JS 8D QC";
81
-		assertEquals(Arrays.asList(doublePairJAndQ),
82
-				new Poker(Arrays.asList(doublePairJAndQ, doublePair2AndQ)).getBestHands());
83
-	}
84
-
85
-	@Ignore("Remove to run test")
86
-	@Test
87
-	public void identicallyRankedPairs() {
88
-		String kicker8 = "JD QH JS 8D QC";
89
-		String kicker2 = "JS QS JC 2D QD";
90
-		assertEquals(Arrays.asList(kicker8), new Poker(Arrays.asList(kicker8, kicker2)).getBestHands());
91
-	}
92
-
93
-	@Ignore("Remove to run test")
94
-	@Test
95
-	public void doublePairVsThree() {
96
-		String doublePair2And8 = "2S 8H 2H 8D JH";
97
-		String threeOf4 = "4S 5H 4C 8S 4H";
98
-		assertEquals(Arrays.asList(threeOf4), new Poker(Arrays.asList(doublePair2And8, threeOf4)).getBestHands());
99
-	}
100
-
101
-	@Ignore("Remove to run test")
102
-	@Test
103
-	public void twoThrees() {
104
-		String threeOf2 = "2S 2H 2C 8D JH";
105
-		String threeOf1 = "4S AH AS 8C AD";
106
-		assertEquals(Arrays.asList(threeOf1), new Poker(Arrays.asList(threeOf2, threeOf1)).getBestHands());
107
-	}
108
-
109
-	@Ignore("Remove to run test")
110
-	@Test
111
-	public void sameThreesMultipleDecks() {
112
-		String remainingCard7 = "4S AH AS 7C AD";
113
-		String remainingCard8 = "4S AH AS 8C AD";
114
-		assertEquals(Arrays.asList(remainingCard8),
115
-				new Poker(Arrays.asList(remainingCard7, remainingCard8)).getBestHands());
116
-	}
117
-
118
-	@Ignore("Remove to run test")
119
-	@Test
120
-	public void threeVsStraight() {
121
-		String threeOf4 = "4S 5H 4C 8D 4H";
122
-		String straight = "3S 4D 2S 6D 5C";
123
-		assertEquals(Arrays.asList(straight), new Poker(Arrays.asList(threeOf4, straight)).getBestHands());
124
-	}
125
-
126
-	@Ignore("Remove to run test")
127
-	@Test
128
-	public void AcesCanEndAStraight() {
129
-		String hand = "4S 5H 4C 8D 4H";
130
-		String straightEndsA = "10D JH QS KD AC";
131
-		assertEquals(Arrays.asList(straightEndsA), new Poker(Arrays.asList(hand, straightEndsA)).getBestHands());
132
-	}
133
-
134
-	@Ignore("Remove to run test")
135
-	@Test
136
-	public void AcesCanStartAStraight() {
137
-		String hand = "4S 5H 4C 8D 4H";
138
-		String straightStartA = "4D AH 3S 2D 5C";
139
-		assertEquals(Arrays.asList(straightStartA), new Poker(Arrays.asList(hand, straightStartA)).getBestHands());
140
-	}
141
-
142
-	@Ignore("Remove to run test")
143
-	@Test
144
-	public void twoStraights() {
145
-		String straightTo8 = "4S 6C 7S 8D 5H";
146
-		String straightTo9 = "5S 7H 8S 9D 6H";
147
-		assertEquals(Arrays.asList(straightTo9), new Poker(Arrays.asList(straightTo8, straightTo9)).getBestHands());
148
-	}
149
-
150
-	@Ignore("Remove to run test")
151
-	@Test
152
-	public void theLowestStraightStartsWithAce() {
153
-		String straight = "2H 3C 4D 5D 6H";
154
-		String straightStartA = "4S AH 3S 2D 5H";
155
-		assertEquals(Arrays.asList(straight), new Poker(Arrays.asList(straight, straightStartA)).getBestHands());
156
-	}
157
-
158
-	@Ignore("Remove to run test")
159
-	@Test
160
-	public void straightVsFlush() {
161
-		String straightTo8 = "4C 6H 7D 8D 5H";
162
-		String flushTo7 = "2S 4S 5S 6S 7S";
163
-		assertEquals(Arrays.asList(flushTo7), new Poker(Arrays.asList(straightTo8, flushTo7)).getBestHands());
164
-	}
165
-
166
-	@Ignore("Remove to run test")
167
-	@Test
168
-	public void twoFlushes() {
169
-		String flushTo8 = "4H 7H 8H 9H 6H";
170
-		String flushTo7 = "2S 4S 5S 6S 7S";
171
-		assertEquals(Arrays.asList(flushTo8), new Poker(Arrays.asList(flushTo8, flushTo7)).getBestHands());
172
-	}
173
-
174
-	@Ignore("Remove to run test")
175
-	@Test
176
-	public void flushVsFull() {
177
-		String flushTo8 = "3H 6H 7H 8H 5H";
178
-		String full = "4S 5H 4C 5D 4H";
179
-		assertEquals(Arrays.asList(full), new Poker(Arrays.asList(full, flushTo8)).getBestHands());
180
-	}
181
-
182
-	@Ignore("Remove to run test")
183
-	@Test
184
-	public void twoFulls() {
185
-		String fullOf4By9 = "4H 4S 4D 9S 9D";
186
-		String fullOf5By8 = "5H 5S 5D 8S 8D";
187
-		assertEquals(Arrays.asList(fullOf5By8), new Poker(Arrays.asList(fullOf4By9, fullOf5By8)).getBestHands());
188
-	}
189
-
190
-	@Ignore("Remove to run test")
191
-	@Test
192
-	public void twoFullssameThripletMultipleDecks() {
193
-		String fullOf5By9 = "5H 5S 5D 9S 9D";
194
-		String fullOf5By8 = "5H 5S 5D 8S 8D";
195
-		assertEquals(Arrays.asList(fullOf5By9), new Poker(Arrays.asList(fullOf5By9, fullOf5By8)).getBestHands());
196
-	}
197
-
198
-	@Ignore("Remove to run test")
199
-	@Test
200
-	public void fullVsSquare() {
201
-		String full = "4S 5H 4D 5D 4H";
202
-		String squareOf3 = "3S 3H 2S 3D 3C";
203
-		assertEquals(Arrays.asList(squareOf3), new Poker(Arrays.asList(full, squareOf3)).getBestHands());
204
-	}
205
-
206
-	@Ignore("Remove to run test")
207
-	@Test
208
-	public void twoSquares() {
209
-		String squareOf2 = "2S 2H 2C 8D 2H";
210
-		String squareOf5 = "4S 5H 5S 5D 5C";
211
-		assertEquals(Arrays.asList(squareOf5), new Poker(Arrays.asList(squareOf2, squareOf5)).getBestHands());
212
-	}
213
-
214
-	@Ignore("Remove to run test")
215
-	@Test
216
-	public void sameSquaresMultipleDecks() {
217
-		String kicker2 = "3S 3H 2S 3D 3C";
218
-		String kicker4 = "3S 3H 4S 3D 3C";
219
-		assertEquals(Arrays.asList(kicker4), new Poker(Arrays.asList(kicker2, kicker4)).getBestHands());
220
-	}
221
-
222
-	@Ignore("Remove to run test")
223
-	@Test
224
-	public void squareVsStraightFlush() {
225
-		String squareOf5 = "4S 5H 5S 5D 5C";
226
-		String straightFlushTo9 = "7S 8S 9S 6S 10S";
227
-		assertEquals(Arrays.asList(straightFlushTo9),
228
-				new Poker(Arrays.asList(squareOf5, straightFlushTo9)).getBestHands());
229
-	}
230
-
231
-	@Ignore("Remove to run test")
232
-	@Test
233
-	public void twoStraightFlushes() {
234
-		String straightFlushTo8 = "4H 6H 7H 8H 5H";
235
-		String straightFlushTo9 = "5S 7S 8S 9S 6S";
236
-		assertEquals(Arrays.asList(straightFlushTo9),
237
-				new Poker(Arrays.asList(straightFlushTo8, straightFlushTo9)).getBestHands());
238
-	}
2
+    @Test
3
+    public void oneHand() {
4
+        String hand = "4S 5S 7H 8D JC";
5
+        assertEquals(Arrays.asList(hand), new Poker(Arrays.asList(hand)).getBestHands());
6
+    }
7
+
8
+    @Ignore("Remove to run test")
9
+    @Test
10
+    public void highestCardWins() {
11
+        String highest8 = "4D 5S 6S 8D 3C";
12
+        String highest10 = "2S 4C 7S 9H 10H";
13
+        String highestJ = "3S 4S 5D 6H JH";
14
+        assertEquals(Arrays.asList(highestJ), new Poker(Arrays.asList(highest8, highest10, highestJ)).getBestHands());
15
+    }
16
+
17
+    @Ignore("Remove to run test")
18
+    @Test
19
+    public void tieHasMultipleWinners() {
20
+        String highest8 = "4D 5S 6S 8D 3C";
21
+        String highest10 = "2S 4C 7S 9H 10H";
22
+        String highestJh = "3S 4S 5D 6H JH";
23
+        String highestJd = "3H 4H 5C 6C JD";
24
+        assertEquals(Arrays.asList(highestJh, highestJd),
25
+                new Poker(Arrays.asList(highest8, highest10, highestJh, highestJd)).getBestHands());
26
+    }
27
+
28
+    @Ignore("Remove to run test")
29
+    @Test
30
+    public void sameHighCards() {
31
+        String nextHighest3 = "3S 5H 6S 8D 7H";
32
+        String nextHighest2 = "2S 5D 6D 8C 7S";
33
+        assertEquals(Arrays.asList(nextHighest3), new Poker(Arrays.asList(nextHighest3, nextHighest2)).getBestHands());
34
+    }
35
+
36
+    @Ignore("Remove to run test")
37
+    @Test
38
+    public void nothingVsOnePair() {
39
+        String nothing = "4S 5H 6C 8D KH";
40
+        String pairOf4 = "2S 4H 6S 4D JH";
41
+        assertEquals(Arrays.asList(pairOf4), new Poker(Arrays.asList(nothing, pairOf4)).getBestHands());
42
+    }
43
+
44
+    @Ignore("Remove to run test")
45
+    @Test
46
+    public void twoPairs() {
47
+        String pairOf2 = "4S 2H 6S 2D JH";
48
+        String pairOf4 = "2S 4H 6C 4D JD";
49
+        assertEquals(Arrays.asList(pairOf4), new Poker(Arrays.asList(pairOf2, pairOf4)).getBestHands());
50
+    }
51
+
52
+    @Ignore("Remove to run test")
53
+    @Test
54
+    public void onePairVsDoublePair() {
55
+        String pairOf8 = "2S 8H 6S 8D JH";
56
+        String doublePair = "4S 5H 4C 8C 5C";
57
+        assertEquals(Arrays.asList(doublePair), new Poker(Arrays.asList(pairOf8, doublePair)).getBestHands());
58
+    }
59
+
60
+    @Ignore("Remove to run test")
61
+    @Test
62
+    public void twoDoublePairs() {
63
+        String doublePair2And8 = "2S 8H 2D 8D 3H";
64
+        String doublePair4And5 = "4S 5H 4C 8S 5D";
65
+        assertEquals(Arrays.asList(doublePair2And8),
66
+                new Poker(Arrays.asList(doublePair2And8, doublePair4And5)).getBestHands());
67
+    }
68
+
69
+    @Ignore("Remove to run test")
70
+    @Test
71
+    public void sameHighestPair() {
72
+        String doublePair2AndQ = "2S QS 2C QD JH";
73
+        String doublePairJAndQ = "JD QH JS 8D QC";
74
+        assertEquals(Arrays.asList(doublePairJAndQ),
75
+                new Poker(Arrays.asList(doublePairJAndQ, doublePair2AndQ)).getBestHands());
76
+    }
77
+
78
+    @Ignore("Remove to run test")
79
+    @Test
80
+    public void identicallyRankedPairs() {
81
+        String kicker8 = "JD QH JS 8D QC";
82
+        String kicker2 = "JS QS JC 2D QD";
83
+        assertEquals(Arrays.asList(kicker8), new Poker(Arrays.asList(kicker8, kicker2)).getBestHands());
84
+    }
85
+
86
+    @Ignore("Remove to run test")
87
+    @Test
88
+    public void doublePairVsThree() {
89
+        String doublePair2And8 = "2S 8H 2H 8D JH";
90
+        String threeOf4 = "4S 5H 4C 8S 4H";
91
+        assertEquals(Collections.singletonList(threeOf4), new Poker(Arrays.asList(doublePair2And8, threeOf4)).getBestHands());
92
+    }
93
+
94
+    @Ignore("Remove to run test")
95
+    @Test
96
+    public void twoThrees() {
97
+        String threeOf2 = "2S 2H 2C 8D JH";
98
+        String threeOf1 = "4S AH AS 8C AD";
99
+        assertEquals(Arrays.asList(threeOf1), new Poker(Arrays.asList(threeOf2, threeOf1)).getBestHands());
100
+    }
101
+
102
+    @Ignore("Remove to run test")
103
+    @Test
104
+    public void sameThreesMultipleDecks() {
105
+        String remainingCard7 = "4S AH AS 7C AD";
106
+        String remainingCard8 = "4S AH AS 8C AD";
107
+        assertEquals(Arrays.asList(remainingCard8),
108
+                new Poker(Arrays.asList(remainingCard7, remainingCard8)).getBestHands());
109
+    }
110
+
111
+    @Ignore("Remove to run test")
112
+    @Test
113
+    public void threeVsStraight() {
114
+        String threeOf4 = "4S 5H 4C 8D 4H";
115
+        String straight = "3S 4D 2S 6D 5C";
116
+        assertEquals(Arrays.asList(straight), new Poker(Arrays.asList(threeOf4, straight)).getBestHands());
117
+    }
118
+
119
+    @Ignore("Remove to run test")
120
+    @Test
121
+    public void AcesCanEndAStraight() {
122
+        String hand = "4S 5H 4C 8D 4H";
123
+        String straightEndsA = "10D JH QS KD AC";
124
+        assertEquals(Arrays.asList(straightEndsA), new Poker(Arrays.asList(hand, straightEndsA)).getBestHands());
125
+    }
126
+
127
+    @Ignore("Remove to run test")
128
+    @Test
129
+    public void AcesCanStartAStraight() {
130
+        String hand = "4S 5H 4C 8D 4H";
131
+        String straightStartA = "4D AH 3S 2D 5C";
132
+        assertEquals(Arrays.asList(straightStartA), new Poker(Arrays.asList(hand, straightStartA)).getBestHands());
133
+    }
134
+
135
+    @Ignore("Remove to run test")
136
+    @Test
137
+    public void twoStraights() {
138
+        String straightTo8 = "4S 6C 7S 8D 5H";
139
+        String straightTo9 = "5S 7H 8S 9D 6H";
140
+        assertEquals(Arrays.asList(straightTo9), new Poker(Arrays.asList(straightTo8, straightTo9)).getBestHands());
141
+    }
142
+
143
+    @Ignore("Remove to run test")
144
+    @Test
145
+    public void theLowestStraightStartsWithAce() {
146
+        String straight = "2H 3C 4D 5D 6H";
147
+        String straightStartA = "4S AH 3S 2D 5H";
148
+        assertEquals(Arrays.asList(straight), new Poker(Arrays.asList(straight, straightStartA)).getBestHands());
149
+    }
150
+
151
+    @Ignore("Remove to run test")
152
+    @Test
153
+    public void straightVsFlush() {
154
+        String straightTo8 = "4C 6H 7D 8D 5H";
155
+        String flushTo7 = "2S 4S 5S 6S 7S";
156
+        assertEquals(Arrays.asList(flushTo7), new Poker(Arrays.asList(straightTo8, flushTo7)).getBestHands());
157
+    }
158
+
159
+    @Ignore("Remove to run test")
160
+    @Test
161
+    public void twoFlushes() {
162
+        String flushTo8 = "4H 7H 8H 9H 6H";
163
+        String flushTo7 = "2S 4S 5S 6S 7S";
164
+        assertEquals(Arrays.asList(flushTo8), new Poker(Arrays.asList(flushTo8, flushTo7)).getBestHands());
165
+    }
166
+
167
+    @Ignore("Remove to run test")
168
+    @Test
169
+    public void flushVsFull() {
170
+        String flushTo8 = "3H 6H 7H 8H 5H";
171
+        String full = "4S 5H 4C 5D 4H";
172
+        assertEquals(Arrays.asList(full), new Poker(Arrays.asList(full, flushTo8)).getBestHands());
173
+    }
174
+
175
+    @Ignore("Remove to run test")
176
+    @Test
177
+    public void twoFulls() {
178
+        String fullOf4By9 = "4H 4S 4D 9S 9D";
179
+        String fullOf5By8 = "5H 5S 5D 8S 8D";
180
+        assertEquals(Arrays.asList(fullOf5By8), new Poker(Arrays.asList(fullOf4By9, fullOf5By8)).getBestHands());
181
+    }
182
+
183
+    @Ignore("Remove to run test")
184
+    @Test
185
+    public void twoFullssameThripletMultipleDecks() {
186
+        String fullOf5By9 = "5H 5S 5D 9S 9D";
187
+        String fullOf5By8 = "5H 5S 5D 8S 8D";
188
+        assertEquals(Arrays.asList(fullOf5By9), new Poker(Arrays.asList(fullOf5By9, fullOf5By8)).getBestHands());
189
+    }
190
+
191
+    @Ignore("Remove to run test")
192
+    @Test
193
+    public void fullVsSquare() {
194
+        String full = "4S 5H 4D 5D 4H";
195
+        String squareOf3 = "3S 3H 2S 3D 3C";
196
+        assertEquals(Arrays.asList(squareOf3), new Poker(Arrays.asList(full, squareOf3)).getBestHands());
197
+    }
198
+
199
+    @Ignore("Remove to run test")
200
+    @Test
201
+    public void twoSquares() {
202
+        String squareOf2 = "2S 2H 2C 8D 2D";
203
+        String squareOf5 = "4S 5H 5S 5D 5C";
204
+        assertEquals(Arrays.asList(squareOf5), new Poker(Arrays.asList(squareOf2, squareOf5)).getBestHands());
205
+    }
206
+
207
+    @Ignore("Remove to run test")
208
+    @Test
209
+    public void sameSquaresMultipleDecks() {
210
+        String kicker2 = "3S 3H 2S 3D 3C";
211
+        String kicker4 = "3S 3H 4S 3D 3C";
212
+        assertEquals(Arrays.asList(kicker4), new Poker(Arrays.asList(kicker2, kicker4)).getBestHands());
213
+    }
214
+
215
+    @Ignore("Remove to run test")
216
+    @Test
217
+    public void squareVsStraightFlush() {
218
+        String squareOf5 = "4S 5H 5S 5D 5C";
219
+        String straightFlushTo9 = "7S 8S 9S 6S 10S";
220
+        assertEquals(Arrays.asList(straightFlushTo9),
221
+                new Poker(Arrays.asList(squareOf5, straightFlushTo9)).getBestHands());
222
+    }
223
+
224
+    @Ignore("Remove to run test")
225
+    @Test
226
+    public void twoStraightFlushes() {
227
+        String straightFlushTo8 = "4H 6H 7H 8H 5H";
228
+        String straightFlushTo9 = "5S 7S 8S 9S 6S";
229
+        assertEquals(Arrays.asList(straightFlushTo9),
230
+                new Poker(Arrays.asList(straightFlushTo8, straightFlushTo9)).getBestHands());
231
+    }
239 232
 }