Problem 116808 · medium · Phase 01 Prerequisites & Setup

Bingo Line Check

nested loops · lists · booleans

card is a square bingo card given as a list of rows (lists of distinct integers) and called is the list of numbers called so far. A player wins when every number in some row or some column has been called (diagonals do not count). Return True if the card has a winning line, otherwise False.

Examples

Input:  card = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], called = [1, 2, 3]
Output: True

Input:  card = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], called = [1, 5, 9]
Output: False

Input:  card = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], called = [3, 6, 9, 2]
Output: True

Constraints

  • 1 <= n <= 10 where the card is n x n; 0 <= len(called) <= 200

Goals

  • Check every row and every column of a grid with nested loops
  • Use a flag or `all`-style logic to test that a whole line is marked
Starting Python…