|
发表于 2020-6-11 10:44:24
|
显示全部楼层
import test
def tickets(people):
sale = []
for i in people:
#print(i)
if i == 25:
sale.append(i)
if i == 50:
if sale.count(25)>=1:
sale.remove(25)
sale.append(i)
else:
return "NO"
if i == 100:
if sale.count(50)>= 1 and sale.count(25)>=1:
sale.remove(50)
sale.remove(25)
sale.append(i)
elif sale.count(25)>=3:
sale.remove(25)
sale.remove(25)
sale.remove(25)
sale.append(i)
else:
return "NO"
return "YES"
test.assert_equals(tickets([25, 25, 50]), 'YES')
test.assert_equals(tickets([25, 100]), 'NO')
test.assert_equals(tickets([25, 25, 25, 25, 25, 25, 25, 25, 25, 25]), 'YES')
test.assert_equals(tickets([50, 50, 50, 50, 50, 50, 50, 50, 50, 50]), 'NO')
test.assert_equals(tickets([100, 100, 100, 100, 100, 100, 100, 100, 100, 100]), 'NO')
test.assert_equals(tickets([25, 25, 25, 25, 50, 100, 50]), 'YES')
test.assert_equals(tickets([50, 100, 100]), 'NO')
test.assert_equals(tickets([25, 25, 100]), 'NO')
test.assert_equals(tickets([25, 25, 50]), 'YES')
test.assert_equals(tickets([25, 25, 25, 25, 25, 25, 25, 50, 50, 50, 100, 100, 100, 100]),'NO')
test.assert_equals(tickets([25, 100]), 'NO')
test.assert_equals(tickets([50, 50, 100]), 'NO')
test.assert_equals(tickets([25, 50, 100]), 'NO')
test.assert_equals(tickets([25, 25, 50, 50, 100]), 'NO')
test.assert_equals(tickets([100, 50, 25, 25]), 'NO')
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
Success!
|
|