This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# comparing kickers | |
def check_kickers(other) | |
return_value = nil | |
self_array = self.highest_hand[:high_cards].sort! | |
other_array = other.highest_hand[:high_cards].sort! | |
if self_array == other_array | |
return_value = 3 | |
else | |
loop do | |
self_num = self_array.pop(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# comparing kickers | |
def check_kickers(other) | |
self.highest_hand[:high_cards].reverse! | |
other.highest_hand[:high_cards].reverse! | |
return_value = nil | |
self.highest_hand[:high_cards].each do |self_card| | |
other.highest_hand[:high_cards].each do |other_card| | |
if self_card > other_card | |
return_value = 1 | |
elsif self_card < other_card |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simple poker hand comparison ## | |
require 'pry' | |
FACE = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" ] | |
SUITS = ["S", "H", "D", "C"] | |
class Deck | |
attr_accessor :cards, :discards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simple poker hand comparison ## | |
require 'pry' | |
FACE = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" ] | |
SUITS = ["S", "H", "D", "C"] | |
class Deck | |
attr_accessor :cards, :discards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simple poker hand comparison ## | |
require 'pry' | |
FACE = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" ] | |
SUITS = ["S", "H", "D", "C"] | |
class Deck | |
attr_accessor :cards, :discards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# finding out if the hand contains a straight and what its high is. | |
def find_straights | |
straight = Array.new | |
@cards.each_with_index do |card, index| | |
binding.pry | |
if index == (@cards.length - 1) | |
straight << card | |
end | |
if (card[:value] += 1) == (@cards[index+1][:value]) | |
straight << card |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simple poker hand comparison ## | |
require 'pry' | |
FACE = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" ] | |
SUITS = ["S", "H", "D", "C"] | |
class Deck | |
attr_accessor :cards, :discards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hand | |
attr_accessor :cards, :highest_hand, :value | |
include Comparable | |
def initialize(cards:, highest_hand:) | |
@cards = cards | |
@highest_hand = highest_hand | |
end | |
def set_value(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grabyo technical test | |
At Grabyo we love board games and will have an occasional poker night. | |
Since no one remembers the card ranking you will have to write a program that | |
compare poker hands and determines a winner. | |
## 1. Task | |
A poker hand has a constructor that accepts a string containing 5 cards: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo = "hello" | |
bar = "world" | |
def my_func foo, bar | |
puts foo | |
puts bar | |
end | |
my_func foo, bar |