Skip to content

Commit

Permalink
Add Part 2 to Day 20. Relatively simple. I just go through each elf a…
Browse files Browse the repository at this point in the history
…nd add their present total to the house total. I sized the array to a random guess, since I'm not worried about memory constraints.
  • Loading branch information
Zachary Boerner authored and Zachary Boerner committed Jan 3, 2016
1 parent 3aef569 commit 8777774
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Day20/Day20.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,21 @@ def factor(n):
print(" Sum: %i" % sum)
print(" Ori: %i" % puzzleNumber)
if sum >= puzzleNumber:
print(factorList)
#print(factorList)
break

numberOfHouses = 1000000 # Also number of elves
numHousesForEachElf = 50

houses = [0 for i in range(0, numberOfHouses)]

# Part 2
for elfNum in range(1, numberOfHouses):
for houseNum in range(1, numHousesForEachElf):
try:
houses[elfNum * houseNum] += elfNum * 11
except IndexError:
break
if houses[elfNum] > puzzleNumber:
print(elfNum)
break;

0 comments on commit 8777774

Please sign in to comment.