euler_poker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/euler_poker.rb +2 -2
- data/lib/euler_poker/{hand.rb → handable.rb} +9 -2
- data/lib/euler_poker/hands/flush.rb +3 -3
- data/lib/euler_poker/hands/four_of_a_kind.rb +3 -3
- data/lib/euler_poker/hands/full_house.rb +3 -3
- data/lib/euler_poker/hands/high_card.rb +3 -3
- data/lib/euler_poker/hands/one_pair.rb +3 -3
- data/lib/euler_poker/hands/straight.rb +3 -3
- data/lib/euler_poker/hands/straight_flush.rb +3 -3
- data/lib/euler_poker/hands/three_of_a_kind.rb +3 -3
- data/lib/euler_poker/hands/two_pair.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b3301dbaf9bda8a4c633827de7e2a288dc7409
|
4
|
+
data.tar.gz: 2611b9ecd1f325c881dbb2d782ca5893f6a0a5e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f85b4798a5d5b60c3ae8127df8e82c92ad78d37e9fe744e968c9f515f35fe1c3264a286e06586d80940fecb2059d238956b7f8c15cf66eff0f694d25bd85fd82
|
7
|
+
data.tar.gz: 4bc4e6155453b205bb79bc771baed5b50d6187b99c3b66da82fab6f1cb6742cdb890c5a66ccb582cc897235b4374ae53a7104295044f2bd6dc6b60808c5d63ed
|
data/lib/euler_poker.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module EulerPoker
|
2
|
-
|
2
|
+
module Handable
|
3
3
|
include Comparable
|
4
4
|
|
5
5
|
def initialize(cards)
|
@@ -7,13 +7,20 @@ module EulerPoker
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def <=>(other)
|
10
|
-
|
10
|
+
class_result = class_comparison(other)
|
11
|
+
return class_result unless class_result == 0
|
12
|
+
|
13
|
+
return instance_comparison(other)
|
11
14
|
end
|
12
15
|
|
13
16
|
def ranking
|
14
17
|
RANKED_HANDS.reverse.index(self.class)
|
15
18
|
end
|
16
19
|
|
20
|
+
def class_comparison(other)
|
21
|
+
ranking <=> other.ranking
|
22
|
+
end
|
23
|
+
|
17
24
|
def ranks
|
18
25
|
@cards.map(&:rank)
|
19
26
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module EulerPoker
|
2
|
-
class ThreeOfAKind
|
3
|
-
|
4
|
-
return super unless super == 0
|
2
|
+
class ThreeOfAKind
|
3
|
+
include Handable
|
5
4
|
|
5
|
+
def instance_comparison(other)
|
6
6
|
if triplet_rank == other.triplet_rank
|
7
7
|
return ranked_extra_cards <=> other.ranked_extra_cards
|
8
8
|
else
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module EulerPoker
|
2
|
-
class TwoPair
|
3
|
-
|
4
|
-
return super unless super == 0
|
2
|
+
class TwoPair
|
3
|
+
include Handable
|
5
4
|
|
5
|
+
def instance_comparison(other)
|
6
6
|
if high_pair_rank != other.high_pair_rank
|
7
7
|
high_pair_rank <=> other.high_pair_rank
|
8
8
|
elsif low_pair_rank != other.low_pair_rank
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: euler_poker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A solution to problem 54 of Project Euler
|
14
14
|
email: rico@toasterlovin.com
|
@@ -21,8 +21,8 @@ files:
|
|
21
21
|
- lib/euler_poker.rb
|
22
22
|
- lib/euler_poker/card.rb
|
23
23
|
- lib/euler_poker/cli.rb
|
24
|
-
- lib/euler_poker/hand.rb
|
25
24
|
- lib/euler_poker/hand_factory.rb
|
25
|
+
- lib/euler_poker/handable.rb
|
26
26
|
- lib/euler_poker/hands/flush.rb
|
27
27
|
- lib/euler_poker/hands/four_of_a_kind.rb
|
28
28
|
- lib/euler_poker/hands/full_house.rb
|