Very Complex Array in VB2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cindy2
    New Member
    • Sep 2007
    • 35

    Very Complex Array in VB2005

    Hi, I have a VERY complex problem. I have posted it under Forums/Visual Basic, but I was strongley recommended to post it here.

    In VB2005 I need a 2D array with x*x elements. There are two cases:

    1) 4 <= x < 8
    2) 8 <= x <= 10

    Case 1)

    Every COLUMN of the array must randomly filt with the letters a, b, c and d. Each column can only have each letter one time. If x is bigger than 4, then the vacanies of each column must be filt with k 's (as many as nescesary).
    Also it's not alloud to have 2 k 's one after the other in a ROW.

    Case 2)

    Every Collumn of the array must randomly filt with the letters a, b, c, d, e, f, g and h. Each colomn can only have each letter one time. If x is bigger than 8, then the vacancies of each column must be filt with k 's (as many as nescesary).
    Also it's not alloud to have 2 k 's one after the other in a Row.


    Does anybody know how I can make this very comlex array???

    Cindy
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by cindy2
    I need a 2D array with x*x elements. There are two cases:

    1) 4 <= x < 8
    2) 8 <= x <= 10

    Case 1)

    Every COLUMN of the array must randomly filt with the letters a, b, c and d. Each column can only have each letter one time. If x is bigger than 4, then the vacanies of each column must be filt with k 's (as many as nescesary).
    Also it's not alloud to have 2 k 's one after the other in a ROW.

    Case 2)

    Every Collumn of the array must randomly filt with the letters a, b, c, d, e, f, g and h. Each colomn can only have each letter one time. If x is bigger than 8, then the vacancies of each column must be filt with k 's (as many as nescesary).
    Also it's not alloud to have 2 k 's one after the other in a Row.
    Hi Cindy!

    I would first calculate, how many k's you need per column. Then find random positions for those k's in the first column (no two of them the same of course) and position them there. Remember the positions and do the same with the second column but check, if you saved one of the values for the previous column and if so, create a new position.

    Continue doing this until you've positioned all k's. Then position the other letters in the columns at random positions (but of course no two letters in the same cell).

    Hope that helps.

    Greetings,
    Nepomuk

    Comment

    Working...