Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.9 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68ee9e3066cfd4eb2328e8a8 Challenge 89: Counting Cards 29 challenge-89

--description--

A standard deck of playing cards has 13 unique cards in each suit. Given an integer representing the number of cards to pick from the deck, return the number of unique combinations of cards you can pick.

  • Order does not matter. Picking card A then card B is the same as picking card B then card A.

For example, given 52, return 1. There's only one combination of 52 cards to pick from a 52 card deck. And given 2, return 1326, There's 1326 card combinations you can end up with when picking 2 cards from the deck.

--hints--

combinations(52) should return 1.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(combinations(52), 1)`)
}})

combinations(1) should return 52.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(combinations(1), 52)`)
}})

combinations(2) should return 1326.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(combinations(2), 1326)`)
}})

combinations(5) should return 2598960.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(combinations(5), 2598960)`)
}})

combinations(10) should return 15820024220.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(combinations(10), 15820024220)`)
}})

combinations(50) should return 1326.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(combinations(50), 1326)`)
}})

--seed--

--seed-contents--

def combinations(cards):

    return cards

--solutions--

from math import factorial
def combinations(cards):
    n = 52
    
    return factorial(n) // (factorial(cards) * factorial(n - cards))