-= Puzzle 12: Bingo Bango Bongo =-

The twelfth and final day of your trial internship at BitFlop Laboratories has arrived! The final obstacle standing between you and a full-time summer unpaid internship is the Internship Bingo Tournament.

Since the company only has room for 1 internship position, they have decided to do an event where all the intern candidates (you included) will compete in a giant game of bingo.

You wonder if they all had to go through the same ordeal as you did to get here.

Before you start, you get 25 bingo cards, with each card having 25 unique numbers on it.

The event goes as follows: the host will call out numbers one by one, and if you have that number on any of your bingo cards, you mark it.

The bingo cards are 5 by 5 grids.

If a complete row, column, or diagonal is marked on any of your bingo cards, that counts as a bingo.

The first person to mark five or more bingos across all their bingo cards wins the event, and therefore the internship.

But theres more! The numbers that the host calls out are not random, instead they are generated before hand and put in a list that is given to you at the start of the event.

Your puzzle input is structured as follows:

The two sections are seperated by a blank line.

As an example, we'll use this smaller test input with only 5 bingo cards and therefore 125 called numbers, but the actual input (your puzzle input) will have 25 bingo cards and 625 called numbers.

62 121 64 51 86 85 36 31 8 113 71 72 75 101 115 44 52 78 26 80 116 98 79 17 77
110 91 10 9 55 74 107 67 93 54 81 25 58 82 56 5 89 32 14 119 48 35 109 47 21
6 69 40 92 68 18 105 66 41 90 22 30 63 57 15 28 125 76 49 65 123 20 16 99 24
108 96 53 87 60 38 73 59 94 83 100 33 111 46 4 106 124 27 104 84 88 42 1 118 12
70 37 39 112 19 7 97 11 114 95 3 120 50 2 61 117 122 102 13 45 103 29 34 23 43

82 39 88 103 71 76 108 109 104 34 49 58 85 107 121 105 67 18 77 118 30 117 26 29 55
6 43 23 96 100 2 47 11 37 24 4 73 120 81 60 112 106 12 92 57 1 54 16 40 31
13 17 3 111 78 56 115 102 124 33 8 122 75 61 25 89 64 20 119 46 113 87 116 44 53
66 38 94 91 36 93 5 45 32 62 42 69 63 28 14 72 86 74 79 9 50 84 80 35 41
10 97 21 83 70 48 90 7 125 15 52 22 51 101 99 19 68 110 114 123 27 65 95 98 59

The first 125 numbers in this example are the numbers that the host will call out, and the next 125 numbers are the numbers on the 5 bingo cards.

The cards are effectively laid out as 5 by 5 grids in reading order.

We can visualize the cards like this:

82  39  88  103 71
76  108 109 104 34
49  58  85  107 121
105 67  18  77  118
30  117 26  29  55

6   43  23  96  100
2   47  11  37  24
4   73  120 81  60
112 106 12  92  57
1   54  16  40  31

13  17  3   111 78
56  115 102 124 33
8   122 75  61  25
89  64  20  119 46
113 87  116 44  53

66  38  94  91  36
93  5   45  32  62
42  69  63  28  14
72  86  74  79  9
50  84  80  35  41

10  97  21  83  70
48  90  7   125 15
52  22  51  101 99
19  68  110 114 123
27  65  95  98  59

With each row being 5 numbers, and each card being 5 rows.

Now, if the host calls out a number, you can consider that number as marked on any of your bingo cards.

As a simple example, if the host calls out the numbers 82, 108, 85, 77, and 55, then the first card would have the following marked numbers:

X   39  88  103 71
76  X   109 104 34
49  58  X   107 121
105 67  18  X   118
30  117 26  29  X

Every time after the host calls a number, you check if any of your cards have a fully marked row, column, or diagonal. And in the quick example above, the card has a completely marked diagonal 82 108 85 77 55, so that counts as a bingo.

A diagonal goes from the top left to the bottom right, or from the top right to the bottom left.

The question is, after which number that the host calls out do you have at least 5 bingos across all your bingo cards for the first time?

For the example, that happens after the host calls out the number 49, which is the 69th number that the host calls out.

All the bingo cards then look like this:

X   39  88  103 X
X   108 X   104 34
X   X   X   X   X
X   X   X   X   118
X   117 X   29  X

X   43  23  96  100
2   X   11  37  24
4   73  120 X   60
112 106 12  X   X
1   X   16  X   X

13  X   3   111 X
X   X   102 124 33
X   122 X   61  X
X   X   20  X   46
X   87  X   X   53

X   38  94  X   X
X   X   45  X   X
42  X   X   X   X
X   X   X   X   X
50  84  X   X   X

X   97  X   83  70
X   X   7   X   X
X   X   X   X   99
19  X   X   114 123
27  65  95  X   59

After what number that the host calls out do you reach at least 5 bingos across your 25 bingo cards for the first time?

You must login to get your input and play!