Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec83671

Browse files
authored
Create Birthday_Chocolate.py
1 parent 5290bec commit ec83671

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the birthday function below.
10+
def birthday(s, d, m):
11+
ans=0
12+
for i in range(len(s)):
13+
n=0
14+
count=0
15+
while(n<(m)):
16+
count+=s[i+n]
17+
n+=1
18+
if(count==d):
19+
ans+=1
20+
if(i+n==len(s)):
21+
break
22+
return ans
23+
24+
if __name__ == '__main__':
25+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
26+
27+
n = int(input().strip())
28+
29+
s = list(map(int, input().rstrip().split()))
30+
31+
dm = input().rstrip().split()
32+
33+
d = int(dm[0])
34+
35+
m = int(dm[1])
36+
37+
result = birthday(s, d, m)
38+
39+
fptr.write(str(result) + '\n')
40+
41+
fptr.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /