-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfb.py
More file actions
27 lines (22 loc) · 772 Bytes
/
fb.py
File metadata and controls
27 lines (22 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sys
def fb(lines):
""" (filename) -> print
Write a program that prints out the the pattern generated by such a
scenario given the values of 'A'/'B' and 'N' which are read from an
input text file. The input text file contains three space delimited
numbers i.e. A, B, N. The program should then print out the final series
of numbers using 'F' for fizz, 'B' for 'buzz' and 'FB' for fizz buzz.
"""
sl = lines.split()
nl = map(int, sl)
i = 0
while i < len(nl):
loop = nl[i:i+3]
for j in range(1,loop[2]+1):
print (not j % loop[0])*'F' + (not j % loop[1])*'B' or j,
i = i + 3
print
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
fb(test)
test_cases.close()