initial Board class that can randomly generate a Bingo board and print itself
This commit is contained in:
commit
8105f468f3
37
bingo-analysis.py
Executable file
37
bingo-analysis.py
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
class Board:
|
||||||
|
def __init__(self):
|
||||||
|
self.cols = []
|
||||||
|
for col in range(5):
|
||||||
|
n = 4 if col == 2 else 5
|
||||||
|
self.cols.append(random.sample(range(15 * col + 1, 15 * col + 15), n))
|
||||||
|
self.cols[2][2:2] = [0]
|
||||||
|
self.border = "+----" * 5 + "+"
|
||||||
|
self.called = {0}
|
||||||
|
|
||||||
|
def print(self):
|
||||||
|
for row in range(5):
|
||||||
|
if row == 0:
|
||||||
|
print(self.border)
|
||||||
|
for col in range(5):
|
||||||
|
caption = self.cols[col][row]
|
||||||
|
if caption == 0:
|
||||||
|
caption = "F"
|
||||||
|
called = "*" if self.cols[col][row] in self.called else " "
|
||||||
|
print("|%s%2s%s" % (called, caption, called), end = "")
|
||||||
|
print("|")
|
||||||
|
print(self.border)
|
||||||
|
|
||||||
|
def call(self, n):
|
||||||
|
self.called.add(n)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
b = Board()
|
||||||
|
b.call(1)
|
||||||
|
b.call(2)
|
||||||
|
b.call(40)
|
||||||
|
b.call(50)
|
||||||
|
b.print()
|
Loading…
x
Reference in New Issue
Block a user