Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This builds an array of the form ex: {1,2,2}
dictKeys.Length=3
dictKeys[] = [100,50,25]


The dictKeys represents box capacities the NumberOfSubBoxes array ({1,2,2}) indicates that a 100 box has 2 x 50 boxes and each having 2 x 25 boxes.

The question is : I want to build another array of the form {100,50,25,25,50,25,25}... Any help ? :S

C#
for (int i = 0;i < dictKeys.Length;i++) {
                if(i+1 < dictKeys.Length) {
                    int numberOfsubBoxes = Convert.ToInt32 (dictKeys[i]) / Convert.ToInt32 (dictKeys[i + 1]);
                    NumberOfSubBoxes[i + 1] = numberOfsubBoxes;
                }
            }
Posted
Updated 1-Nov-10 22:38pm
v2
Comments
Keith Barrow 2-Nov-10 4:23am    
I'm just making a sanity check, so don't take this the wrong way. Why do you need a 7-dimesional array? It is unusual to need 4 dimensions, very unusual for 5, but there are a few circumstances where a 7D array might be legitimate.
Dalek Dave 2-Nov-10 4:38am    
Edited for Grammar and Readability.
qontary 2-Nov-10 5:28am    
I think the question meaning is not what it seems. Is {100,50,25,25,50,25,25} the output OR the input OR the dimension???

1 solution

Are you absolutely sure?
Even if each element of your 7 dimensional array is a single byte, you will need 100 * 50 * 25 * 25 * 50 * 25 * 25 bytes to store it.

97,656,250,000 bytes.

97GB of RAM, if it is 1 byte per element.

I think you need to rethink your project, just a bit!
 
Share this answer
 
Comments
Toli Cuturicu 2-Nov-10 9:33am    
You are right.
The OP has either not formulated the question properly, or has a very severe algorithm issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900