Fixed a sorting problem :/
This commit is contained in:
parent
f1fbe33d23
commit
de46c0daf2
1 changed files with 7 additions and 5 deletions
12
054.rb
12
054.rb
|
@ -254,7 +254,7 @@ def tonumber(hand)
|
|||
when 'K' then 13
|
||||
when 'A' then 14
|
||||
end
|
||||
end
|
||||
end.sort
|
||||
end
|
||||
|
||||
def highest_card(hand1,hand2)
|
||||
|
@ -278,9 +278,9 @@ def win(h)
|
|||
hand2=h[1]
|
||||
|
||||
cat1=Category.new(hand1)
|
||||
puts "HAND1: #{cat1.to_s}"
|
||||
# puts "HAND1: #{cat1.to_s}"
|
||||
cat2=Category.new(hand2)
|
||||
puts "HAND2: #{cat2.to_s}"
|
||||
# puts "HAND2: #{cat2.to_s}"
|
||||
|
||||
# Best category win
|
||||
if cat1.cat > cat2.cat
|
||||
|
@ -312,10 +312,12 @@ end
|
|||
sum=0
|
||||
hands.each do |h|
|
||||
if win(h)
|
||||
puts "PLAYER 1 (WIN)"
|
||||
# puts "PLAYER 1 (WIN)"
|
||||
puts "True"
|
||||
sum+=1
|
||||
else
|
||||
puts "PLAYER 2 (LOSE)"
|
||||
puts "False"
|
||||
# puts "PLAYER 2 (LOSE)"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue