Skip to content

Instantly share code, notes, and snippets.

@BharathKumarS
Created February 19, 2020 05:50
Show Gist options
  • Save BharathKumarS/ebc6118eeb7e64dcc4e480ea9d26b648 to your computer and use it in GitHub Desktop.
Save BharathKumarS/ebc6118eeb7e64dcc4e480ea9d26b648 to your computer and use it in GitHub Desktop.
Birthday Chocolates from HackerRank
#This is a test case check. Please check my git repo for the actual solution to go into HackerRank
def choco(s,d,m):
can = 0
if len(s) > 1:
for sq in range(len(s)-m):
if sum(s[sq:sq+m]) == d:
can += 1
else:
if s[0] == d:
can = 1
print(can)
s = [2,5,1,3,4,4,3,5,1,1,2,1,4,1,3,3,4,2,1]
d = 18
m = 7
choco(s,d,m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment