-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vasya-Clerk.py
31 lines (31 loc) · 1.12 KB
/
Vasya-Clerk.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
#Challenge is to see if the cashier will have change for all the people in line
#The "people" argument is a list of the bills that the patrons have- either a $25
#$50, or $100 bill. Can the cashier sell a ticker to each person and give the change
#if he initially has no money and sells the tickets strictly in the order people
#follow in line?
def tickets(people):
if people[0] != 25:
return ('NO')
change = [people[0]]
for i in range(1,len(people)):
if people[i] == 25:
change.append(people[i])
elif people[i] == 50:
if 25 in change:
change.remove(25)
change.append(50)
else:
return('NO')
elif people[i] == 100:
if change.count(25) >=3:
change.remove(25)
change.remove(25)
change.remove(25)
change.append(100)
elif change.count(50) >= 1 and change.count(25) >=1:
change.remove(50)
change.remove(25)
change.append(100)
else:
return('NO')
return('YES')