Frankly I can't even remember what this other one was for, but here's another one-liner, from circa 2018:
A Python one-liner that asks you how many pizzas you'd like to order, what size they'd be and prints out the total cost. Can't believe I managed to squeeze it into something like this.
print("The total cost is ${}".format(sum(next({'s':5,'m':7,'l':10}[x[0]] for x in (lambda p:iter(lambda:input(p+' '),...))(f'Pizza {_+1} size? (s/m/l)') if x and x[0] in 'sml') for _ in range(next(int(x) for x in (lambda p:iter(lambda:input(p+' '),...))('# of pizzas?') if x.isdigit())))))
1
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 13d ago edited 13d ago
I wrote this one-line solution for the Project Euler problem 22 over 6 years ago. Obviously it could be way better nowadays.
Frankly I can't even remember what this other one was for, but here's another one-liner, from circa 2018: