PDA

View Full Version : finding 12 numbers that'll give me the most result in a row of an array



kman
05-10-2013, 07:08 AM
Hi,
I have an exercise to solve.
I have an array of 20 lines and in each line there are 6 random numbers from 1-37.
I need to find 12 numbers that will maximize the times thatall 6 numbers in a row Are between my 12 numbers

I am attaching a sample file,
in the example the 12 numbers 1,8,12,13,19,27,28,30,33,34,35,37 are at 6 full row numbers 2,8,9 ( lines mark in red)

I am looking for a way to find the 12 numbers that will maximize the lines that all 6 numbers are in my 12 numbers,

Thanks

SamT
05-10-2013, 09:13 AM
Kamn,

Welcome to VBA Express. We don't do homework, but we will help you work your own way through it.

I suggest you consider a method to store winning numbers; A winning number count loop; Inside that loop, a winning number count limit loop; And inside that, a number existence loop.

Evrey time a number count limit is reached, store that number and increment the Winning number count loop.

For 1 to 12
For 6 to 1
For 1 to 37
For each cell Then If cell = 1-37 then counter = counter + 1
If counter = limit Then store number