Page 2 of 2 FirstFirst 12
Results 41 to 46 of 46

Thread: Random Unique Lists of 12 Numbers

  1. #41
    Hyperactive Member Lenggries's Avatar
    Join Date
    Sep 2009
    Posts
    353

    Re: Random Unique Lists of 12 Numbers

    Except that the OP specifically says that the program needs to "create lists untill no more strings can be create." Like the other requirements, it's a bit vague, but as this thread has gone well beyond the point of merely helping him with his homework assignment, it is not unreasonable for us to consider some of the ramifications of both creation and storage.

    That said, a 1-for-1 hashing between a random integer and a valid sequence, as you suggest, is almost certainly the ideal solution for sequence generation. I'm sure it could be done by almost everyone that has posted in this thread so far, but doing so and posting the solution here would hand the OP an A+ on a silver platter, and frankly, I don't think he's earned it yet.

  2. #42
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Random Unique Lists of 12 Numbers

    You can't create more when you run out of memory ^___^

  3. #43
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Random Unique Lists of 12 Numbers

    If I've read the requirements correctly. The first valid sequence is(sorted) 0,1,2,3,4,5,6,7,8,9,10,11, and the last valid sequence would be 79,80,81,82,83,84,85,86,87,88,89,90(again, sorted).

    You can basically store this information in an array of type byte with 12 indices. Dim Numbers(11) as Byte '0 to 11 = 12 indices

    Well, I suppose we should start from the beginning, so lets initialize Numbers() to the minimum sequence:
    Code:
    For x = 1 To 11
      Numbers(x) = x
    Next x
    Then we'll want to check, inside a Do loop, for any duplicates in Numbers(). So do a For x = 0 to 10, and nested inside of that, for loop y = (x + 1) to 11. This will go through every possible combination only once.

    Code:
      For x = 0 To 10
        For y = x + 1 To 11
          If Numbers(x) = Numbers(y) Then GoTo AGAIN 'two numbers match, yes... a goto really is the easiest(most efficient) way to break out of nested loops
        Next y
      Next x
    You could also unroll that for more speed(do it without the loops, the much longer way).

    Line label AGAIN can be the place in the routine where Numbers() is incremented(and carry over). Just like addition:
    Code:
    AGAIN: 'increment
    
      Numbers(0) = Numbers(0) + 1
      For x = 0 To 10
        If Numbers(x) > 90 Then
          Numbers(x + 1) = Numbers(x + 1) + 1
          Numbers(x) = Numbers(x) - 90
        End If
      Next x
    The Loop on the Do loop should be approximately around here.

    I would suggest sorting valid Numbers() prior to storing them. This will make it easier(more efficient) to check for preexisting valid matches.

    The bonus to incrementing over randomization is you can easily pause and resume the process at any time, and you're not generating the same sequences repeatedly.

    Good luck, as I'm not going to code your entire assignment for you(but I have no problem answering questions).

  4. #44
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Random Unique Lists of 12 Numbers

    Homework or Assignment? That was just an assumption so far.

    Quote Originally Posted by Lenggries View Post
    That said, a 1-for-1 hashing between a random integer and a valid sequence, as you suggest, is almost certainly the ideal solution for sequence generation. I'm sure it could be done by almost everyone that has posted in this thread so far, but doing so and posting the solution here would hand the OP an A+ on a silver platter, and frankly, I don't think he's earned it yet.
    That does not include me. I cannot do it.

    Quote Originally Posted by FireXtol View Post
    Good luck, as I'm not going to code your entire assignment for you(but I have no problem answering questions).
    I have a big problem answering the question.
    Please code it here so I (and may be others) can learn, not just the OP.
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #45
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Random Unique Lists of 12 Numbers

    Quote Originally Posted by anhn View Post
    Homework or Assignment? That was just an assumption so far.
    The OP said "This is a very very hard project for me and i need an A.;(" so we assume it's a school project of some sorts.

  6. #46
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Random Unique Lists of 12 Numbers

    Quote Originally Posted by baja_yu View Post
    .."Just avoid holding it in that way." - Steve Jobs ..
    Priceless !

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width