Compare commits

..

No commits in common. "521cef0e58239c51141f3dfafb5672cd6bd00f84" and "dc85aadc3aa78c629fb8978d3cbfe8bd5de651c2" have entirely different histories.

2 changed files with 3 additions and 24 deletions

View file

@ -1,19 +0,0 @@
import sys
changes = [int(line.rstrip()) for line in sys.stdin.readlines()]
# Part 1
print("Simple sum:", sum(changes))
# Part 2
freq = 0
history = {0: True}
found = False
while not found:
for c in changes:
freq += c
if freq in history:
found = True
break
history[freq] = True
print("First repeated:", freq)

View file

@ -1,18 +1,16 @@
from datetime import datetime
import os import os
import requests import requests
import sys import sys
if len(sys.argv) < 2: if len(sys.argv) != 2:
print("Usage: <fetch> day") print("Usage: <fetch> day")
sys.exit() sys.exit()
day = sys.argv[1] day = sys.argv[1]
year = sys.argv[2] if len(sys.argv) > 2 else str(datetime.now().year)
URL = "https://adventofcode.com/{}/day/{}/input" URL = "https://adventofcode.com/2019/day/{}/input"
SESSION_ID = os.environ["AOC_SESSION"] SESSION_ID = os.environ["AOC_SESSION"]
response = requests.get(URL.format(year, day), cookies={"session": SESSION_ID}) response = requests.get(URL.format(day), cookies={"session": SESSION_ID})
response.raise_for_status() response.raise_for_status()
with open("day{}.txt".format(day), "wt") as output_file: with open("day{}.txt".format(day), "wt") as output_file: