tracks/swift/exercises/poker/Sources/PokerExample.swift in trackler-2.1.0.53 vs tracks/swift/exercises/poker/Sources/PokerExample.swift in trackler-2.1.0.54
- old
+ new
@@ -45,19 +45,19 @@
case fourOfAKind(four:Rank)
case straightFlush(Rank, Suit)
func order() -> Int {
switch self {
- case .highCard(_): return 1
- case .onePair(_, card1: _, card2: _, card3: _): return 2
- case .twoPair(high: _, low: _, highCard: _): return 3
- case .threeOfAKind(three:_): return 4
- case .straight(high:_): return 5
- case .flush(_, _): return 6
- case .fullHouse(three:_): return 7
- case .fourOfAKind(four:_): return 8
- case .straightFlush(_, _): return 9
+ case .highCard: return 1
+ case .onePair: return 2
+ case .twoPair: return 3
+ case .threeOfAKind: return 4
+ case .straight: return 5
+ case .flush: return 6
+ case .fullHouse: return 7
+ case .fourOfAKind: return 8
+ case .straightFlush: return 9
}
}
static func parsePairs(_ inputHand: PokerHand) -> [(rank: Rank, count: Int)] {
let ranks = inputHand.hand.map({ $0.rank })
@@ -183,10 +183,11 @@
default:
return false
}
}
// swiftlint:disable:next cyclomatic_complexity
+// swiftlint:disable:next empty_enum_arguments
func < (lhs: HandRank, rhs: HandRank) -> Bool {
switch (lhs, rhs) {
case (_, _) where lhs == rhs:
return false
@@ -238,9 +239,10 @@
default:
return lhs.order() < rhs.order()
}
}
+// swiftlint:enable:next empty_enum_arguments
struct PokerHand {
let hand: [PlayingCard]
func handRank() -> HandRank {