crobertsbmw / deckofcards

An API to simulate a deck of cards
MIT License
1.34k stars 335 forks source link

Draw n cards and reshuffle between every request #117

Open 01231 opened 2 years ago

01231 commented 2 years ago

I'd like to draw a card of a shuffle deck, then reshuffle and repeat this process n times. With this approach the probability to draw a card would be 1/52 on every request and would not increase with every drawn card.

I'm using a workaround where I do this manually in a loop, but I though this would be a cool functionality to add...

crobertsbmw commented 2 years ago

Would it be easier/better to just pull a random number out of 52 n times, rather than loop the API request?

On Wed, May 18, 2022 at 8:47 AM Noah @.***> wrote:

I'd like to draw a card of a shuffle deck, then reshuffle and repeat this process n times. With this approach the probability to draw a card would be 1/52 on every request and would not increase with every drawn card.

I'm using a workaround where I do this manually in a loop, but I though this would be a cool functionality to add...

— Reply to this email directly, view it on GitHub https://github.com/crobertsbmw/deckofcards/issues/117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMQLHTNTQRFN5GO6ZJMG6TVKT7IVANCNFSM5WIXVICA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

01231 commented 2 years ago

Indeed! I changed my implementation.

However this would still be a cool feature to have. I was surprised that this functionality wasn't implemented yet, since I though this is a normal use case. As you said you can pull a random number out of 52 in the background. But I think it would be cleaner to access this functionality over the API.