Fall, 2020
Due: Oct 20 by 11:55 pm (London ON time)
Complete both Part 1 and Part 2 of Advent of Code 2015 Day 2.
Please make sure to save your puzzle input as a file called A4_input.txt
Your code should assume that the input is in a file named A4_input.txt
This will allow us to run your code locally to veryify that it works.
Hint: In Part 1 and in Part 2 you will need to find the smallest of three quantities. You can use the built-in function min()
to do this:
# in Part 1:
= min(l*w,l*h,w*h)
slack
# in Part 2:
= 2*min(l+w,l+h,w+h) ribbon
Hint: To load in the input file line by line there are many ways to do it, but here is one way:
with open("A4_input.txt") as fp:
for line in fp:
= map(int,line.split('x')) l,w,h
Here is another way that will use the NumPy function genfromtxt()
to load in the entire file into one big 2D array:
import numpy as np
= np.genfromtxt('A4_input.txt', delimiter='x') a4
There are other ways to read in the file as well. Whatever works for you is fine.