Skip to content

Instantly share code, notes, and snippets.

@vpatov
Created August 17, 2017 14:23
Show Gist options
  • Save vpatov/0a616d52a22ad7991e5ce2473897c75d to your computer and use it in GitHub Desktop.
Save vpatov/0a616d52a22ad7991e5ce2473897c75d to your computer and use it in GitHub Desktop.
Problem 3
"""
If you want to use a dictionary
"""
galaxies = {}
with open('input_3.txt','r') as f:
for line in f:
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 = []
with open('input_3.txt','r') as f:
for line in f:
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