https://www.hackerrank.com/challenges/the-birthday-bar/problem
HackerRank - Birthday Chocolate
#!/bin/python3import mathimport osimport randomimport reimport sysdef birthday(s, d, m): count = 0 for i in range(0, len(s)-m+1): if(int(sum(s[i:i+m])) == d): count += 1 return countif __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()
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
| HackerRank - Migratory Birds (0) | 2019.01.24 |
|---|---|
| HackerRank - Divisible Sum Pairs (0) | 2019.01.23 |
| HackerRank - Breaking the Records (0) | 2019.01.21 |
| HackerRank - Between Two Sets (0) | 2019.01.20 |
| HackerRank - Kangaroo (0) | 2019.01.19 |