Skip to content

Instantly share code, notes, and snippets.

@h3matite
h3matite / day2_pt1.py
Created December 2, 2019 06:27
Advent of Code Day 2
def run_program(data):
for i in range(0, len(data), 4):
if i == 0 or i%4 == 0:
if data[i] == 99:
return data[0]
elif data[i] == 1:
data[data[i+3]] = data[data[i+1]] + data[data[i+2]]
elif data[i] == 2:
data[data[i+3]] = data[data[i+1]] * data[data[i+2]]
else:
@h3matite
h3matite / day1_pt1.py
Last active December 2, 2019 06:29
Advent of Code Day 1
def calc_fuel(mass):
return (int(mass.strip()) // 3) - 2
## Load Data
with open("input.txt", "r") as f:
module_weights = f.readlines()
## Find Required Fuel
fuel = sum([calc_fuel(x) for x in module_weights])
print("Day1, Part1 --", fuel)