-
Notifications
You must be signed in to change notification settings - Fork 0
/
20.py
35 lines (26 loc) · 800 Bytes
/
20.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
from math import sqrt
def solve(data):
for house in range(1, int(data / 10) + 1):
if sum([
e + house / e for e in range(1, int(sqrt(house) + 1))
if house % e == 0
]) * 10 >= data:
return house
def solve2(data):
for house in range(1, int(data / 11) + 1):
divs = list()
for e in range(1, int(sqrt(house) + 1)):
if house % e == 0:
if e * 50 >= house:
divs += [e]
if int(house / e) * 50 >= house:
divs += [int(house / e)]
if sum(divs) * 11 >= data:
return house
def tests():
assert solve(140) == 8
assert solve(70) == 4
print('tests pass')
tests()
print(solve(29000000))
print(solve2(29000000))