Generate Pairwise-Distinct Bingo Boards
Problem statement
Generate boardCount pairwise-distinct 5 x 5 Bingo boards and return each board as one row-major array of 25 integers.
- Board row 0 contains five distinct values from 1 through 15, row 1 from 16 through 30, and so on through row 4 from 61 through 75.
- Every output cell must consume exactly one random choice.
- The first cell of every board must be different, which guarantees that all returned boards are pairwise distinct.
Use this reproducible random rule. Set state = seed. A call next(bound) first sets state = (1103515245 * state + 12345) mod 2^31, then returns state mod bound.
Maintain one shared swap-with-last pool [1..15] for the first cell of each board. For each board, choose that first cell with one call to next(poolSize) and remove it by swapping with the pool's last value. Then create a fresh full row-0 pool [1..15], remove the reserved value by the same swap-with-last operation without a random call, and choose its remaining four cells. For every later board row, create its fresh 15-value range and choose five cells by the same one-call swap-with-last selection. Preserve the generated order.
Function
generateBingoBoards(boardCount: int, seed: int) → int[][]Examples
Example 1
boardCount = 1seed = 0return = [[1,3,2,5,14,24,17,26,25,18,33,39,36,41,45,49,57,46,59,52,72,61,71,74,68]]The 25 seeded choices generate one valid row-major board.
Example 2
boardCount = 2seed = 0return = [[1,3,2,5,14,24,17,26,25,18,33,39,36,41,45,49,57,46,59,52,72,61,71,74,68],[9,4,15,10,6,26,18,17,30,25,32,45,43,42,31,60,54,57,59,56,63,64,67,66,70]]The shared first-cell pool gives the boards different first cells, 1 and 9.
Example 3
boardCount = 1seed = 7return = [[7,2,8,4,14,17,22,21,16,19,31,38,43,36,39,53,52,60,56,49,63,70,62,72,75]]A different seed changes the deterministic sequence while preserving every row range and uniqueness rule.
Constraints
1 <= boardCount <= 5.0 <= seed <= 2147483647.- All arithmetic in the random-state update must preserve the mathematical modulo-
2^31result.