92.1k views
4 votes
In a round of Bingo, every player gets a 5x5 grid of spaces. Every space has a number, and the columns are

each given a letter: B, I, N, G, O. The person running the game then calls out spaces by their letter and number, such as B 13, 0 74, etc.
Numbers are not purely randomly distributed, though.

Numbers in the B column always come between 1 and 15.
Numbers in the I column always come between 16 and 30.
Numbers in the N column always come between 31 and 45.

Numbers in the G column always come between 46 and 60.

Numbers in the 0 column always come between 61 and 75.
So, certain letter-number combinations are invalid. So, B17 would be invalid because column B is only numbers
#1 through 17. J 63 would be invalid because J is not one of the letters on a bingo board. 0 117 would be invalid because 117 is not one of the numbers ever on a bingo board.

Write a function called bingo_checker. bingo checker should take as input two parameters, both strings representing a letter and a number. bingo_checker should return True if the letter-number combination represents a valid spot on a Bingo card, False otherwise.

Using python

User Chry Cheng
by
8.0k points

1 Answer

5 votes

Final answer:

The bingo_checker function in Python can be defined to check whether a given letter-number combination is a valid spot on a Bingo card. The function takes two parameters, both strings representing a letter and a number. The function will return True if the combination is valid and False otherwise.

Step-by-step explanation:

The bingo_checker function in Python can be defined to check whether a given letter-number combination is a valid spot on a Bingo card. The function takes two parameters, both strings representing a letter and a number. The function will return True if the combination is valid and False otherwise.

In order to determine the validity of the combination, the function can check if the letter is one of the valid letters on a Bingo card, and if the number falls within the range of numbers associated with that letter. For example, if the letter is 'B' and the number is 8, the combination would be considered valid. However, if the letter is 'N' and the number is 50, the combination would be considered invalid.

Here is an example implementation of the bingo_checker function:

def bingo_checker(letter, number):
valid_letters = ['B', 'I', 'N', 'G', 'O']
letter_index = valid_letters.index(letter)
number = int(number)
if letter_index == 0 and 1 <= number <= 15:
return True
elif letter_index == 1 and 16 <= number <= 30:
return True
elif letter_index == 2 and 31 <= number <= 45:
return True
elif letter_index == 3 and 46 <= number <= 60:
return True
elif letter_index == 4 and 61 <= number <= 75:
return True
else:
return False
User Shawnett
by
8.1k points