-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhalloween_game_HR.py
53 lines (41 loc) · 1 KB
/
halloween_game_HR.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the howManyGames function below.
def howManyGames(p, d, m, s):
# Return the number of games you can buy
if s>p:
cost=p
count=1
s=s-p
while s>0:
if cost>m:
cost=cost-d
if cost<m:
cost=m
s=s-cost
if s>=0:
count=count+1
else:
cost=cost
s=s-cost
if s>=0:
count=count+1
else:
break
else:
count=0
return count
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
pdms = input().split()
p = int(pdms[0])
d = int(pdms[1])
m = int(pdms[2])
s = int(pdms[3])
answer = howManyGames(p, d, m, s)
fptr.write(str(answer) + '\n')
fptr.close()