2015: d20: ex1: add solution
This commit is contained in:
parent
8d739cd487
commit
4c511702fc
1 changed files with 24 additions and 0 deletions
24
2015/d20/ex1/ex1.py
Executable file
24
2015/d20/ex1/ex1.py
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def solve(input: str) -> int:
|
||||
needed = int(input.strip())
|
||||
presents = [0] * (needed // 10) # Surely this should be enough houses
|
||||
for i in range(1, len(presents)):
|
||||
for j in range(i, len(presents), i):
|
||||
presents[j] += 10 * i
|
||||
for i, total in enumerate(presents):
|
||||
if total >= needed:
|
||||
return i
|
||||
assert False # Sanity check
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = sys.stdin.read()
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue