-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfizzBuzz.py
40 lines (35 loc) · 1.02 KB
/
fizzBuzz.py
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
33
34
35
36
37
38
39
40
class fizzBuzz():
def __init__(self, n):
self.n = n
def solutionA(self):
ans = []
for i in range(self.n):
if (i % 3 == 0 and i % 5 == 0):
ans.append('fizzbuzz')
elif (i % 3 == 0):
ans.append('fizz')
elif (i % 5 == 0):
ans.append('buzz')
else:
ans.append(i)
return ans
def solutionB(self):
ans = []
for i in range(self.n):
if (i % 3 == 0):
if (i % 5 == 0):
ans.append('fizzbuzz')
else:
ans.append('fizz')
elif (i % 5 == 0):
ans.append('buzz')
else:
ans.append(i)
return ans
obj = fizzBuzz(4)
resA = obj.solutionA()
resB = obj.solutionB()
for i in range(len(resA)):
if (resA[i] != resB[i]):
print("discrepency")
print("both solutions are admissable and equivalent")