'=========================================================================== ' Subject: QUICK SHUFFLE Date: 12-10-95 (13:30) ' Author: Bill White Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: FAQS.ABC '=========================================================================== '> I am working on a program that needs to have random numbers '> between 0 and 255 without repeating any number once.... and '> i would also like to know how to store each number in an '> array and compare it to the imput of a file. ' Here's my routine for shuffling cards. You can ' expand and adapt it to your needs: 'Quick Shuffle 'This shuffle routine is faster than what people usually use 'because there is no need to check for duplications. 'In the programs in which this has been used, all computations 'have been done with the numbers from 1 to 52 for simplicity. 'The conversion to suits and rank was done only at print-out time. COLOR 7, 1 CLS DIM card(52) RANDOMIZE TIMER 'Initialize pack 'Make each element in the array FOR i = 1 TO 52 'equal to its position value, i.e., card(i) = i 'first card = 1, second card = 2, etc. NEXT i 'Like a new deck of cards: no dupes. 'Shuffle 'Exchange each card in the pack with FOR i = 1 TO 52 'a card picked at random. r = INT(RND(1) * 52) + 1 SWAP card(i), card(r) NEXT i 'View results 'Just a demo of the results. FOR i = 1 TO 52 'This is where you pick the card(s) PRINT card(i), 'you want to use (deal). NEXT i