Array Indexes -VBA

Kenya649

Member
I have basic programming skills in both Visual Basic and C/C++.
My problem is to create an an Array such that its indexes is its contents (and how to access the contents) or any other method that can solve my problem.

Example:
Assume I have the following numbers 1,2,3,4,5 and combine then into three. the Array should have
1,2,3
1,2,4
1,2,5
1,3,4
1,3,5
1,4,5
2,3,4
2,3,5
2,4,5
3,4,5

as it's contents and same index such then whenever I want to search for a three number combination, I should use index instead of looping the whole array.
e.g if I want to know if {1,3,4},{1,3,5} and {3,4,5} is in the Array I should move direct to the line.

I hope I'm clear.

Basically I do not want to use looping technique to search for an entry in an array.

Thanks

Kanya649
 

GillesD

Member
Array or formula

I am not too sure about what you want exactly and looping through data would have been my choice but I have though of one possible way to obtain the result.

First, create a string with all combinations with a distinctive character between each, such as 010203-010204-010205-010304-010305-010405-020304-020305-020405-030405.

Then, use the FIND function to search for each combination in a formula such as =FIND(B5,A1,1) where B5 would contain the string "010203" (what you are looking for), A1 the string mentionned previously and 1 the position to start looking for. If the string you are looking for is present, you will get a number (indicating its position) or an error message if not present.

If you are looking for 3 different strings, just enter a formula adding 3 FIND functions and if the result is a number, it will indicate that all 3 are present, otherwise an error will result in at least 1 of them is not present.

I hope this could can help you.
 

hopefull

Member
needs an answer

GillesD said:
I am not too sure about what you want exactly and looping through data would have been my choice but I have though of one possible way to obtain the result.

First, create a string with all combinations with a distinctive character between each, such as 010203-010204-010205-010304-010305-010405-020304-020305-020405-030405.

Then, use the FIND function to search for each combination in a formula such as =FIND(B5,A1,1) where B5 would contain the string "010203" (what you are looking for), A1 the string mentionned previously and 1 the position to start looking for. If the string you are looking for is present, you will get a number (indicating its position) or an error message if not present.

If you are looking for 3 different strings, just enter a formula adding 3 FIND functions and if the result is a number, it will indicate that all 3 are present, otherwise an error will result in at least 1 of them is not present.

I hope this could can help you.
what do you think you answer this > hi all. does any one play the 6/49 5 number combination?
it is because I think the 5 number combination is a fraud.
what do you think ?
I'll explain how if some one comments on this.
 

Kenya649

Member
Thanks GillesD,

I thought of the same over the weekend and declared a one dimensional Array with 444546474849 as its element.

For C/C++ programmers how do you declare such a huge array without getting Array size too large error?

My program is much faster than using the loops.

Thanks
 

CMF

Member
I reply only because someone reading your post could be easily misled.

The most elementary of introductions to arrays will tell you to simulate a table with an index you create a 2 Dimensional Array; the first dimension is your index or row number - the second dimension holds your values.

For those that really program skiting about coding in a dozen languages does not impress; whether one is logical, the preeminent requirement in programming can be picked up on by an experienced person in a few sentences or lines of code.

Regards
Colin Fairbrother
 
The IS a way of calculating the index directly from the numbers.
This can be done using 'combinadics'.
If you search for that you will find a good explanation at http://en.wikipedia.org/wiki/Combinadic
Another (easier but slower way) would be storing the values in an array (13983816 long for 6/49) and using a binary search on them.
 

Sidebar

Top