-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfizzbuzz.py
More file actions
34 lines (27 loc) · 778 Bytes
/
fizzbuzz.py
File metadata and controls
34 lines (27 loc) · 778 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
25
26
27
28
29
30
31
32
import sys
# Sample input
'''
3 5 10
2 7 15
'''
with open("data.txt", 'r') as test_cases:
data = [x.strip() for x in test_cases.readlines()]
content = data
for line in data:
# splitting file data AND casting data from file to integer
t = [int(x.strip()) for x in line.split(' ')]
final = ""
for x in range(1, t[2] + 1):
if ((x % t[0]) == 0 and (x % t[1]) == 0):
final += "FB "
elif ((x % t[0]) == 0):
final += "F "
elif ((x % t[1]) == 0):
final += "B "
else:
final += str(x) + " "
final.strip() #removing trailing spaces
print(final)
# Output
#1 2 F 4 B F 7 8 F B
#1 F 3 F 5 F B F 9 F 11 F 13 FB 15