You're sick of other players smugly announcing "BINGO" and walking triumphantly past you to claim their prize. This time it will be different. You bribed the caller to give you the BINGO calls ahead of time, in the order they will be called. Now you just need to create a BINGO board that will win as early as possible for those calls, guaranteeing you a win (or an unlikely tie).
Given a delimited string or list of the calls in order, in typical BINGO format (letters included, e.g.
G68, see the rules for more info), output a matrix or 2D list representing an optimal BINGO board for those calls. Assume input will always be valid.
- 5x5 board
- A "BINGO" is when your card has 5 numbers in a row from the numbers that have been called so far.
- The center square is free (automatically counted towards a BINGO), and may be represented by whitespace, an empty list,
- The 5 columns are represented by the letters
- The first column may contain the numbers 1-15, the second 16-30, ..., and the fifth 61-75.
- The letters and numbers taken for input may optionally be delimited (by something that makes sense, like a
,or space) or taken as a tuple of a character and a number.
- Output requires only numbers in each place in the matrix.
- Squares that will not contribute to your early BINGO must be valid, but do not have to be optimal.
- This is code-golf, shortest code wins
I'm using this input format for the examples, because it's shorter. See the section above for acceptable input/output formats.
O61 B2 N36 G47 I16 N35 I21 O64 G48 O73 I30 N33 I17 N43 G46 O72 I19 O71 B14 B7 G50 B1 I22 B8 N40 B13 B6 N37 O70 G55 G58 G52 B3 B4 N34 I28 I29 O65 B11 G51 I23 G56 G59 I27 I25 G54 O66 N45 O67 O75 N42 O62 N31 N38 N41 G57 N39 B9 G60 I20 N32 B15 O63 N44 B10 I26 O68 G53 I18 B12 O69 G49 B5 O74 I24 Possible Output (this has a horizontal BINGO in 3rd row. A diagonal is also possible.): [[11,25,42,53,68], [ 6,22,32,57,62], [ 2,16, 0,47,61], [ 3,17,37,59,75], [ 9,19,41,46,70]] N42 N34 O66 N40 B6 O65 O63 N41 B3 G54 N45 I16 O67 N31 I28 B2 B14 G51 N36 N33 I23 B11 I17 I27 N44 I24 O75 N38 G50 G58 B12 O62 I18 B5 O74 G60 I26 B8 I22 N35 B1 B4 G53 O73 G52 O68 B10 O70 I30 G59 N43 N39 B9 G46 G55 O64 O61 I29 G56 G48 G49 I19 G57 N37 O72 I25 N32 B13 B7 B15 O71 I21 I20 O69 G47 Must be a vertical BINGO in 3rd (N) column (because 4 N's came before one of each B,I,G,O): [[11,25,42,53,63], [ 2,22,34,57,65], [ 6,16, 0,47,66], [ 3,17,41,54,75], [ 9,19,40,46,70]]