Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- somma=0
- d={'one':'1','two':'2','three':'3','four':'4','five':'5','six':'6','seven':'7','eight':'8','nine':'9','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'8','9':'9'}
- with open("input") as file:
- data = file.read().splitlines()
- for line in data:
- f = dict.fromkeys(d.keys(), 0)
- rf = dict.fromkeys(d.keys(), 0)
- for c in d.keys():
- f[c] = line.find(c) if line.find(c) != -1 else 100000
- rf[c] = line.rfind(c)
- #primacifra = d[min(f, key=f.get)]
- #secondacifra = d[max(rf, key=rf.get)]
- somma+=10*int(d[min(f, key=f.get)])+int(d[max(rf, key=rf.get)])
- print(somma)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement