-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMax Candy.py
More file actions
25 lines (20 loc) · 815 Bytes
/
Max Candy.py
File metadata and controls
25 lines (20 loc) · 815 Bytes
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
#!/usr/bin/python
'''
Given the array candies and the integer extraCandies, where candies[i]
represents the number of candies that the ith kid has.
For each kid check if there is a way to distribute extraCandies among
the kids such that he or she can have the greatest number of candies
among them. Notice that multiple kids can have the greatest number of candies.
'''
def main():
n = int(input("Enter number of kids : "))
candies = list(map(int,input("Enter the number of candies each kid has : ").strip().split()))[:n]
extra = int(input("Enter the extra candy count : "))
for i in range(0, n):
a = candies[i] + extra
if (a >= max(candies)):
print("true")
else:
print("false")
if __name__ == "__main__":
main()