Created
August 17, 2017 14:23
-
-
Save vpatov/0a616d52a22ad7991e5ce2473897c75d to your computer and use it in GitHub Desktop.
Problem 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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