Skip to content

Instantly share code, notes, and snippets.

@vpatov
Created August 7, 2017 14:59
Show Gist options
  • Save vpatov/e30c1107f988e30e962b6667a73683c3 to your computer and use it in GitHub Desktop.
Save vpatov/e30c1107f988e30e962b6667a73683c3 to your computer and use it in GitHub Desktop.
"""
If you want to use a dictionary
"""
galaxies = {}
for line in open('problem1_input.txt','r'):
parts = map(str.strip,line.split(','))
name,x,y,benefit = parts
galaxies[name] = {"x":int(x), "y":int(y), "benefit": int(benefit)}
"""
If you want a list of tuples
"""
galaxies = []
for line in open('problem1_input.txt','r'):
parts = map(str.strip,line.split(','))
name,x,y,benefit = parts
galaxies.append((name,int(x),int(y),int(benefit)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment