minus-squarecalvin@lemmy.calvss.comtoAdvent Of Code@programming.dev•🎄 - 2023 DAY 1 SOLUTIONS -🎄linkfedilinkarrow-up0·11 months 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
calvin@lemmy.calvss.comM to test@lemmy.calvss.com · 1 year agoTest green.pnglemmy.calvss.comimagemessage-square0fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageTest green.pnglemmy.calvss.comcalvin@lemmy.calvss.comM to test@lemmy.calvss.com · 1 year agomessage-square0fedilink
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")]))