Click here to Skip to main content
15,900,254 members
Home / Discussions / C#
   

C#

 
GeneralRe: read coulmn from file and store it to array Pin
sudany_zool15-Jan-09 3:31
sudany_zool15-Jan-09 3:31 
GeneralRe: read coulmn from file and store it to array Pin
SeMartens15-Jan-09 3:42
SeMartens15-Jan-09 3:42 
GeneralRe: read coulmn from file and store it to array Pin
sudany_zool15-Jan-09 3:59
sudany_zool15-Jan-09 3:59 
QuestionReaderWriterLock Pin
the_jat15-Jan-09 2:30
the_jat15-Jan-09 2:30 
AnswerRe: ReaderWriterLock Pin
Luc Pattyn15-Jan-09 2:53
sitebuilderLuc Pattyn15-Jan-09 2:53 
AnswerRe: ReaderWriterLock Pin
Jon Rista16-Jan-09 6:57
Jon Rista16-Jan-09 6:57 
AnswerRe: ReaderWriterLock Pin
Mark Salsbery16-Jan-09 7:50
Mark Salsbery16-Jan-09 7:50 
QuestionDrawing cards from a deck Pin
Tony Pottier15-Jan-09 2:18
Tony Pottier15-Jan-09 2:18 
Hi,

I'd like to run some simulations on a deck of 52 cards, but I don't know how to make it fast.

Say, I want to draw 5 random cards from a deck. The most straightforward way to do this would be to create a List<string>, List<card>, List<int>, etc. (whatever way the cards are represented), then draw a random number between 0-51, remove the card from the list, draw a number between 0-50, remove the card from the list, rinse & repeat until 5 cards are drawn.

The problem is that adding/removing stuff is a costly operation. Can you see a fast way to randomly draw cards from a deck?
AnswerRe: Drawing cards from a deck Pin
CPallini15-Jan-09 2:41
mveCPallini15-Jan-09 2:41 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:01
Tony Pottier15-Jan-09 4:01 
AnswerRe: Drawing cards from a deck Pin
benjymous15-Jan-09 2:50
benjymous15-Jan-09 2:50 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:03
Tony Pottier15-Jan-09 4:03 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:16
Tony Pottier15-Jan-09 4:16 
GeneralRe: Drawing cards from a deck Pin
benjymous15-Jan-09 4:55
benjymous15-Jan-09 4:55 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 5:56
Guffa15-Jan-09 5:56 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 5:38
sitebuilderLuc Pattyn15-Jan-09 5:38 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 6:32
Guffa15-Jan-09 6:32 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 6:40
Tony Pottier15-Jan-09 6:40 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 6:42
sitebuilderLuc Pattyn15-Jan-09 6:42 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 6:55
Guffa15-Jan-09 6:55 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 6:59
sitebuilderLuc Pattyn15-Jan-09 6:59 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 7:27
Tony Pottier15-Jan-09 7:27 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 7:31
sitebuilderLuc Pattyn15-Jan-09 7:31 
AnswerRe: Drawing cards from a deck Pin
Henry Minute15-Jan-09 12:34
Henry Minute15-Jan-09 12:34 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 12:42
Tony Pottier15-Jan-09 12:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.