minus-squarecalvin@lemmy.calvss.comtoAdvent Of Code@programming.dev•🎄 - 2023 DAY 1 SOLUTIONS -🎄linkfedilinkarrow-up3·1 year agoI wanted to see if it was possible to do part 1 in a single line of Python: print(sum([(([int(i) for i in line if i.isdigit()][0]) * 10 + [int(i) for i in line if i.isdigit()][-1]) for line in open("input.txt")])) linkfedilink
I wanted to see if it was possible to do part 1 in a single line of Python:
print(sum([(([int(i) for i in line if i.isdigit()][0]) * 10 + [int(i) for i in line if i.isdigit()][-1]) for line in open("input.txt")]))