Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Compute Probability of Ace of Diamonds in a Poker Hand
func testPokerAceOfDiamonds()
{
let handsWithAceOfDiamonds = Binomial(n: 51, choose: 4)
let allPossibleHands = Binomial(n: 52, choose: 5)
let probabilityOfAceOfDiamonds = handsWithAceOfDiamonds / allPossibleHands
XCTAssertEqual(probabilityOfAceOfDiamonds, Rational(5,52))
let probabilityOfNoAceOfDiamonds = Rational(1) - probabilityOfAceOfDiamonds
XCTAssertEqual(probabilityOfNoAceOfDiamonds, Rational(47,52))
}
Owner

rayfix commented Jun 22, 2014

This example uses my simple RAFIntMath framework. https://github.com/rayfix/RAFIntMath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment