-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtickets.py
36 lines (26 loc) · 987 Bytes
/
tickets.py
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
def tickets(people):
print people
bill_count = {}
if people[0] > 25:
return "NO"
for item in people:
print bill_count
if item == 25:
bill_count[item] = bill_count.get(item, 0) + 1
else:
if item == 50:
if 25 in bill_count and bill_count[25] > 0:
bill_count[25] -= 1
bill_count[item] = bill_count.get(item, 0) + 1
else:
return "NO"
elif item == 100:
if 50 in bill_count and bill_count[50] > 0 and 25 in bill_count and bill_count[25] > 0:
bill_count[50] -= 1
bill_count[25] -= 1
elif 25 in bill_count and bill_count[25] >= 3:
bill_count[25] -= 3
else:
return "NO"
return "YES"
tickets([25, 50, 50])