Skip to content

Instantly share code, notes, and snippets.

# 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)
# 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
## 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
## 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
## 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
# 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
## 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
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)
# 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:
foo = "hello"
bar = "world"
def my_func foo, bar
puts foo
puts bar
end
my_func foo, bar