Next challenge is to show random values in each cell Now I created a 3*9 region and filled the cells with 1s or 0s, “1” when the cell in bingo ticket is supposed to have a value and “0” if the cell is empty as shown below: Selecting any five cells out of nine cells You can see the first five such combinations in the image below: So I listed all these combinations in a table and then randomly selected one of the combinations. The trick here is that first column in our 3*9 bingo ticket has any number(s) from 1 to 9, second column has any number(s) from 10 to 19 …Īgain, the challenge is the numbers should not repeat, otherwise we could simply use rand()*10, rand()*10+10, rand()*10+20. ![]() ![]() If the column has 2 values, we will generate 2 random numbers without repetition from that column’s range of possible values and place them in cells that are supposed to have them.If the column has 1 value, we will generate any random number from that column’s range of possible values (1-9, 10-19,20-29,…80-89) and place it in the cell that is supposed to have a value and leave other cells empty.If the column has no values in it, then we will leave all the cells in that column of bingo ticket empty.The ticket generation logic now looks like: This time it gets even more trickier because each column can have either no values, or 1 value or 2 values or 3 values.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |