2015: d20: ex2: add solution
This commit is contained in:
parent
0259d9bbf7
commit
235f801f41
1 changed files with 26 additions and 0 deletions
26
2015/d20/ex2/ex2.py
Executable file
26
2015/d20/ex2/ex2.py
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/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(1, 50 + 1):
|
||||
if (i * j) >= len(presents):
|
||||
continue
|
||||
presents[i * j] += 11 * 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