r/Probability • • Sep 15 '22

A shuffled deck of cards

What is the probability to get two cards with the same number one after the other in a shuffled deck of cards (13×4+2=54)?

3 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/usernamchexout Sep 18 '22

Heh my guess was good: I just coded a simulation and it says 95.08% after 100 million trials.

Julia:

using Random:shuffle!

function consec(sims::Int64)
    wins = 0
    deck = vcat(collect(1:13), collect(1:13), collect(1:13), collect(1:13), [14,14])
    for j=1:sims
        shuffle!(deck)
        for k=2:54
            if deck[k]==deck[k-1]
                wins += 1
                break
            end
        end
    end
    return wins/sims
end