Distribution of #'s across an array of sub groups

This is a discussion on Distribution of #'s across an array of sub groups within the C++ Programming forums, part of the General Programming Boards category; What's the best distribution algorithm to use if I want to place numbers 1, 2, and 3 in an array. ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    Distribution of #'s across an array of sub groups

    What's the best distribution algorithm to use if I want to place numbers 1, 2, and 3 in an array. The array can be variable length and so can the number of occurrences of 1,2,and 3. The array is however grouped into sub groups all of the same size and the number 1 can only appear max once per subgroup, the number three many times, and the number two can only be placed more than once in a subgroup after each subgroup has received one. The issue is that the distance between the last placed number (may be across sub groups, or within sub groups) can not be passed. So if the distance is 10 within a group, we can't go more than 10 array spots without having a number placed, if the distance is across groups than we can't go more than 10 without having a number placed within and across groups. I want to randomize it as well, choosing sub groups and/or position in sub groups at random whether using a linear or circular approach. I guess an approach would be to do shuffling afterward if we did violate the distance restriction, but I'm not sure if that would ruin what we tried to accomplish by placing the numbers in the first place. If anybody has any suggestions or links they can refer me to that would help, math isn't my strong suit. Thanks.
    Last edited by tempster09; 08-14-2010 at 10:17 AM.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Show some code and we will help.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    47
    That's the problem, I don't know how to code a solution since I have no idea how to approach it. I don't actually need a solution just a starting point maybe, like an idea of how to approach it. Or some links to look at that will point me in the right direction. Than I can code something for debate.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Allow me to assist:

    What's the best distribution algorithm to use if I want to place numbers 1, 2, and 3 in an array.
    The array can be variable length and so can the number of occurrences of 1,2,and 3.

    The array is however grouped into sub groups all of the same size and the number 1 can only appear max once per subgroup, the number three many times, and the number two can only be placed more than once in a subgroup after each subgroup has received one. The issue is that the distance between the last placed number (may be across sub groups, or within sub groups) can not be passed.
    So if the distance is 10 within a group, we can't go more than 10 array spots without having a number placed, if the distance is across groups than we can't go more than 10 without having a number placed within and across groups.
    I want to randomize it as well, choosing sub groups and/or position in sub groups at random whether using a linear or circular approach. I guess an approach would be to do shuffling afterward if we did violate the distance restriction, but I'm not sure if that would ruin what we tried to accomplish by placing the numbers in the first place. If anybody has any suggestions or links they can refer me to that would help, math isn't my strong suit. Thanks.
    There are enough keywords in your post to almost write an entire program without the actual algorithm being put into place. You should at least, from your post, understand the data structure that you will need and how you will need to design the system to support the given requirements.

    Sorry, I don't buy that you don't know where to start. Think about it, do some bit of design in UML or something, and then post what you come up with. Post the UML if you want to but post something. You have been given very clear requirements (be thankful) with which to start designing with. I'd help more but it's the weekend and I'm most assuredly not at work nor getting paid for this.
    Last edited by VirtualAce; 08-14-2010 at 12:07 PM.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    47
    There's already a design in place, we have several classes and headers giving us thousands of lines of source code. I gave myself the requirement....it's my project, i simplified the problem to its basic concepts and posted on here, this solution simply provides input for other modules so I only need a function, it's not necessary to design classes and structures for this problem, it's too small a piece of the puzzle that takes input, creates output, and provides it as input to another component of our system. I can' t post the whole project, it's too large and confusing, and I can't post a portion cause it won't make sense. I can solve the problem, the issue is doing it properly so when you step back and do statistical analysis it accomplishes eveness and no biased placement, so it changes the nature of a "solution", meaning one I come up with won't be much use since it won't be "correct" because I don't have a math background. I don't care if you give me code, I want an idea, a theorem to study, a link to somewhere i can read some articles.... It's like asking the question "how should i do this" - "use a linked list", "ok great, i'll code it myself"....why do you think I want you to complete this for me? Why should i code a solution that doesn't even come anywhere near to what I want so i have to re-write the whole thing to get it right...There's a solution, than there's a right solution....i don't think you understand this concept. I don't care about code structure, design, I care about the approach, the pseudo code, the ideas, the concepts, the debate about an approach....this is a tiny piece to a jig saw puzzle i am going to place, i don't want you to create the piece, I just want an idea about how I can create the piece so it actually fits!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 02:28 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21