I'm trying to come up with an algorithm that will prdocue random bingo tickets (6 tickets to a strip).

Each ticket must show three rows of five numbers from range [1,90] with one, two or three numbers from each sub-ranges [1,9], [10,19].....,[70,79],[80,90] in each colum. Each ticket must show all diferent numbers and be different from all other tickets. Furthermore tickets are come in 'sixes' so that all 90 numbers apear on each page. An example as

---------------------------------------
|2 |    |27|   |   |45|56|61|    |   |  
---------------------------------------
|   |13|28|   |   |46|    |62|   |81|
----------------------------------------
|7 |    |   |35|   |   |    |66|75|88|

so, im trying to work out an algorithm which i could run for each strip that would give me 6 strings that represet 6 tickets that make up a strip. an example string:

5.13.32.78.81^7.14.34.51.62^9.21.39.42.54

Has anyone had to do anything like this before? The algorithms im trying to come up with at the moment just don't feel efficient. I'm sure theres better ways.

regards

I would: Create a 'pool' containing the 90 numbers, shuffle the pool so that all of the numbers are mixed, and then select them as needed in the order they appear in the pool ( i.e. random ). This is much the same as a bingo caller picking numbers really.

It's not inefficient; because you need to guarantee that the same number isn't chosen twice. Any method to achieve that limit would need to either select numbers in some non-repeating order from a set of all of the possible numbers; or check generated numbers against previously generated numbers. Checking generated numbers against existing numbers is highly innefficient because towards the end of the generation sequence; there's only a few numbers left to select from ( and the computer may NEVER pick them [ unlikely but possible ] ). Another method would be maintaining an ordered ( non-random ) list of numbers, selecting a random list index and then removing the index ( shortening the list ).. But; that means dynamically changing the list.. and for some reason it seems less random/more predictable in some way... But; I can't explain why I think that, or prove that it is the case. Walking through a shuffled pool means totally constant fetch time ( after arbitrary shuffle time ).

What's the algorithm you're using at the moment? I'm not quite sure that I understand the whole tickets/strips/rows/ranges etc thing.. It sounds complicated! ... I don't play bingo.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.