-
Notifications
You must be signed in to change notification settings - Fork 0
/
Birthday Candles
43 lines (34 loc) · 1.05 KB
/
Birthday Candles
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
#You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age.
#They will only be able to blow out the tallest of the candles. Count how many candles are tallest.
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'birthdayCakeCandles' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY candles as parameter.
#
def birthdayCakeCandles(candles):
n = len(candles)
max = 0
count = 0
for x in range(n):
if candles[x] > max:
max = candles[x]
count = 1
elif candles[x] == max:
count +=1
return count
or comment out the above and
return candles.count(max(candles))
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
candles_count = int(input().strip())
candles = list(map(int, input().rstrip().split()))
result = birthdayCakeCandles(candles)
fptr.write(str(result) + '\n')
fptr.close()