Skip to contents

Calculates the total score for a Blackjack hand. Aces count as 11 unless it causes a bust.

Usage

score_hand(hand)

Arguments

hand

A character vector of cards.

Value

An integer representing the total score.

Examples

score_hand(c("A♠", "10♣"))  # 21
#> [1] 21
score_hand(c("A♠", "A♦", "9♠"))  # 21
#> [1] 21
score_hand(c("A♠", "A♦", "A♣", "10♠"))  # 13
#> [1] 13