# Day 20 - Advent of Code 2015

Working solutions for the day 20 puzzles.

### Part One

``````""" day_20_01.py """

# usage: python3 day_20_01.py < input

import math

def sum_factors(dividend):
""" sum factors of dividend """
factors = set()
limit = int(math.sqrt(dividend))
for i in range(1, limit + 1):
quotient, remainder = divmod(dividend, i)
if remainder == 0:
return sum(factors)

presents = int(input())

house = 1
while sum_factors(house) * 10 < presents:
house += 1
print(house)
``````

### Part Two

``````""" day_20_02.py """

# usage: python3 day_20_02.py < input

import math

def sum_limited_factors(dividend):
""" sum limited factors of dividend """
factors = set()
limit = int(math.sqrt(dividend))
for i in range(1, limit + 1):
quotient, remainder = divmod(dividend, i)
if remainder == 0:
if quotient <= 50:
if i <= 50:
return sum(factors)

presents = int(input())

house = 1
while sum_limited_factors(house) * 11 < presents:
house += 1
print(house)
``````

### Last posts

1. Day 19 - Advent of Code 2015
2. Day 18 - Advent of Code 2015
3. Day 17 - Advent of Code 2015
4. Day 16 - Advent of Code 2015
5. Day 15 - Advent of Code 2015