-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBirthdaybar.py
52 lines (41 loc) · 1.06 KB
/
Birthdaybar.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
41
42
43
44
45
46
47
48
49
50
51
52
#https://www.hackerrank.com/challenges/the-birthday-bar/problem
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the birthday function below.
def birthday(s, d, m):
count=0
window=[]
if len(s)<m:
return count
if len(s)==1 and m==1:
if s[0]==d:
count+=1
return count
else:
return count
if len(s)>1 and len(s)>m:
for i in range(0,len(s)-m+1):
sumwindow=0
for j in range(0,m):
sumwindow+=s[i+j]
print("i is"+str(i))
print("sumwindow is"+str(sumwindow))
if sumwindow==d:
count+=1
window=[]
return 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()