OFFSET
1,2
COMMENTS
The most common way of evaluating a bridge hand (13 cards from a standard deck) is to count a jack as 1 point, a queen as 2 points, a king as 3 points, and an ace as 4 points, and add them together. (Suits are ignored.)
EXAMPLE
a(2)=2 because you can have a total of 2 points in two ways: two jacks or one queen, and a(3)=3 because you can have a total of 3 points in three ways: one king, one queen plus one jack, or three jacks.
PROG
(R)
card_values <- c(
Ace = 4,
King = 3,
Queen = 2,
Jack = 1
)
combinations <- function(n) {
count <- 0
for (a in 0:4) {
for (k in 0:4) {
for (q in 0:4) {
for (j in 0:4) {
if (a + k + q + j <= 13 &&
a * card_values['Ace'] + k * card_values['King'] + q * card_values['Queen'] + j * card_values['Jack'] == n) {
count <- count + 1
}
}
}
}
}
return(count)
}
results_vector <- c()
for (n in 1:37) {
output <- combinations(n)
if (output > 0) {
results_vector <- c(results_vector, output)
}
}
format_output <- paste(results_vector, collapse = ", ")
cat(format_output)
# W. Kyle Hamilton, Oct 01 2023
(PARI) a363058(n) = {my (c=0); for (a=0, 4, for (k=0, 4, for (q=0, 4, for (j=0, 4, if (a+k+q+j<=13 && 4*a+3*k+2*q+j==n, c++))))); c};
for (n=1, 37, print1(a363058(n), ", ")) \\ Hugo Pfoertner, Oct 01 2023
CROSSREFS
KEYWORD
nonn,fini,full
AUTHOR
Jud McCranie, May 16 2023
STATUS
approved