Skip to content

Instantly share code, notes, and snippets.

@maiamcc
Created December 4, 2020 23:58
Show Gist options
  • Save maiamcc/f529589b6b7de802f7b0eb977b57bb65 to your computer and use it in GitHub Desktop.
Save maiamcc/f529589b6b7de802f7b0eb977b57bb65 to your computer and use it in GitHub Desktop.
xfile = open('advent_day1.txt')
inp= xfile.read()
# you've got a big string that's many lines of text, and each line is a number.
inp = inp.trim() # get rid of extra space on either side of the big string
lines = inp.split('\n') # make a list by splitting on every linebreak (\n is the newline character)
ints = []
for line in lines:
ints.append(int(line)) # make sure the elements in your list are numbers you can do math with, not just strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment