Created
December 19, 2016 05:34
-
-
Save BraedenYoung/675d1c96459ff8c85f0517555ebaea7a to your computer and use it in GitHub Desktop.
DAY19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from termcolor import cprint | |
SAMPLES = """ | |
5 | |
""" | |
def part_one(input): | |
cprint("Day 19: part one ", 'green') | |
# input = SAMPLES | |
party_size = 0 | |
elves = {} | |
for line in input.splitlines(): | |
if not line: | |
continue | |
party_size = int(line) | |
for elf in range(1, party_size+1): | |
elves[elf] = 1 | |
print white_elephant(elves) | |
def white_elephant(elves): | |
while True: | |
something_stolen = False | |
for elf in elves: | |
if elves[elf] > 0: | |
for i in range(1, len(elves)-1): | |
vitim_elf = ((elf+i) % len(elves)) or len(elves) | |
if elves[vitim_elf] > 0: | |
elves[elf] += elves[vitim_elf] | |
elves[vitim_elf] = 0 | |
something_stolen = True | |
break | |
if not something_stolen: | |
break | |
for elf in elves: | |
if elves[elf] > 0: | |
print elf | |
def part_two(input): | |
cprint("Day 19: part two ", 'green') | |
# for line in input.splitlines(): | |
# if not line: | |
# continue | |
# party_size = int(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment