![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Nov 2007
Posts: 86
Rep Power: 1
![]() |
Re: populate array with random nonrepeating #'s
that is a lot of work to do two things. 1) create an enumerable of a series of integers 2) shuffle any enumerable of any type
your code only works for a very specialized case. |
|
|
|
|
|
#12 |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 895
Rep Power: 4
![]() |
Re: populate array with random nonrepeating #'s
This topic was discussed not too long ago in this thread. In post #8, I offered a solution using generics that will shuffle an array. Thus, you can easily create a 42-element array, initialize each element (inside a
for() loop), and then hand the array off to be shuffled. This guarantees each value will appear once, and only once, within the array.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Nov 2007
Posts: 86
Rep Power: 1
![]() |
Re: populate array with random nonrepeating #'s
your use of generics allows you to shuffle any type of array. my class allows for any type and any container to be shuffled. my series class is really not part of the exercise.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning Values into Random Index's in Array | csrocker101 | C# | 9 | Mar 20th, 2008 3:46 AM |
| Random image array | Smessed-Up | JavaScript and Client-Side Browser Scripting | 3 | Mar 7th, 2008 7:40 PM |
| ADA Random Seed of an Array | scm007 | Other Programming Languages | 1 | Mar 25th, 2007 9:05 PM |
| random numbers in 2D array | cwl157 | Java | 4 | Apr 29th, 2005 6:08 AM |
| Installing IPB 2.03 | bh4575 | Other Web Development Languages | 0 | Apr 23rd, 2005 2:36 AM |