<commit_before>class BlackjackValue
  def initialize(hand)
    @hand = hand
  end

  def values
    {"Two" => 2, "Three" => 3, "Four" => 4, "Five" => 5, "Six" => 6,
    "Seven" => 7, "Eight" => 8, "Nine" => 9, "Ten" => 10, "Jack" => 10,
    "Queen" => 10, "King" => 10, "Ace" => 11}
  end

  def value
    hand_value = @hand.reduce(0) { |sum, card| sum + values[card.rank] }

    ace_count = @hand.count { |card| card.include?("Ace") }
    if hand_value > 21 && ace_count > 0
      until hand_value <= 21 || ace_count == 0
        hand_value -= 10 unless ace_count == 0
        ace_count -= 1
      end
    end
    
    hand_value
  end

  def is_blackjack
    if @hand.length > 2
      false
    else
      has_ace = true if @hand.each { |c| c[:rank] == "Ace" }
      has_jack = true if @hand.each { |c| c[:rank] == "Jack" }

      true if has_ace && has_jack
    end
  end
end<commit_msg>Resove issue where every hand was being considered a blackjack<commit_after>class BlackjackValue
  def initialize(hand)
    @hand = hand
  end

  def values
    {"Two" => 2, "Three" => 3, "Four" => 4, "Five" => 5, "Six" => 6,
    "Seven" => 7, "Eight" => 8, "Nine" => 9, "Ten" => 10, "Jack" => 10,
    "Queen" => 10, "King" => 10, "Ace" => 11}
  end

  def value
    hand_value = @hand.reduce(0) { |sum, card| sum + values[card.rank] }

    ace_count = @hand.count { |card| card.include?("Ace") }
    if hand_value > 21 && ace_count > 0
      until hand_value <= 21 || ace_count == 0
        hand_value -= 10 unless ace_count == 0
        ace_count -= 1
      end
    end
    
    hand_value
  end

  def is_blackjack
    if @hand.length > 2
      false
    else
      has_ace = has_jack = nil

      @hand.each { |c| has_ace  = true if c[:rank] == "Ace"  }
      @hand.each { |c| has_jack = true if c[:rank] == "Jack" }

      true if has_ace && has_jack
    end
  end
end
{'fraction_non_alphanumeric': 0.1610305958132045, 'fraction_numerical': 0.0322061191626409, 'mean_word_length': 2.293286219081272, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4206190', 'n_tokens_mistral': 770, 'n_tokens_neox': 688, 'n_words': 205}