-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathsolution.py
More file actions
37 lines (26 loc) · 729 Bytes
/
solution.py
File metadata and controls
37 lines (26 loc) · 729 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
33
34
35
36
37
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the birthday function below.
def birthday(squares, d, m):
count = 0
#go till length of bar-bithday month
for i in range(0,len(squares)+1-m):
#if sum of m squares is equal to d increament the count
if sum(squares[i:i+m]) == d:
count+=1
#return the count
return count
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip())
s = list(map(int, input().rstrip().split()))
dm = input().rstrip().split()
d = int(dm[0])
m = int(dm[1])
result = birthday(s, d, m)
fptr.write(str(result) + '\n')
fptr.close()