PDA

Click to See Complete Forum and Search --> : creating a list of unsorted numbers


Pouncer
Jul 30th, 2008, 05:02 AM
i have an editbox in which i can enter a number between 1000-5000

and i need to create a list/array of unsorted numbers.

for e.g, if i enter 1500 in the box and click on the button 'Start'

it should create an array/list of numbers 1,2,3,....,1500 (but all mixed up)

any ideas guys?

Steve_F
Jul 30th, 2008, 01:50 PM
Generate the list in order first. Then create a new blank list. Have another list that contains which spots are open. Generate a random number from 0 to the size of the last list mentioned and place the next number in the first list in it. Then remove that from the list of possibilities and generate again.

pgag45
Aug 1st, 2008, 04:11 PM
I think a more efficient way would be to check out

Collections.shuffle()