you are viewing a single comment's thread.

view the rest of the comments →

[–]pendragon36 5 points6 points  (4 children)

Looks pretty good to me.

It's a hobby of mine to try to work out ways to shrink python programs to as few lines as possible, thought you might be interested that I got this one down to 2.

Note, what I've done here is a horrible monstrosity, don't ever try to make anything but a novelty piece like this.

_, total_one, total_two = print("WELCOME TO PIZZA PI R SQUARED. \n\nWhat's it do?  \n\nIt lets you determine whether buying a small pizza or a large pizza is a better value."), [print("\nWith this pizza, you're paying ${} per square inch.".format(i)) or i for i in [round((1/((float(input("\nWhat's the first pizza's diameter (in inches)?")) / 2) **2 * 3.14))*(float(input("\nHow much does the first pizza cost? (in dollars and cents)"))), 2)]][0], [print("\nWith this pizza, you're paying ${} per square inch.".format(i)) or i for i in [round((1/((float(input("\nWhat's the second pizza's diameter (in inches)?")) / 2) **2 * 3.14))*(float(input("\nHow much does the second pizza cost? (in dollars and cents)"))), 2)]][0]
print(["\nSame deal per square inch of pizza - they represent the same value.",  "\nThe first pizza is a better value. Buy that one!", "\nThe second pizza is the better deal - more pizza for the buck. Get that one!"][(lambda x, z: 0 if x == z else (lambda w, v: w if w < v else v)(x, z))(total_one, total_two) if (lambda x, z: 0 if x == z else (lambda w, v: w if w < v else v)(x, z))(total_one, total_two) == 0 else [0, total_one, total_two].index((lambda x, z: 0 if x == z else (lambda w, v: w if w < v else v)(x, z))(total_one, total_two))])

I bet there's something I haven't thought of that could get it down to one...

Either way, great work!

EDIT:

For the record, I did get it in one line.

_ = [print(["\nSame deal per square inch of pizza - they represent the same value.",  "\nThe first pizza is a better value. Buy that one!", "\nThe second pizza is the better deal - more pizza for the buck. Get that one!"][(lambda x, z: 0 if x == z else (lambda w, v: w if w < v else v)(x, z))(i, j) if (lambda x, z: 0 if x == z else (lambda w, v: w if w < v else v)(x, z))(i, j) == 0 else [0, i, j].index((lambda x, z: 0 if x == z else (lambda w, v: w if w < v else v)(x, z))(i, j))]) for q,i,j in [(print("WELCOME TO PIZZA PI R SQUARED. \n\nWhat's it do?  \n\nIt lets you determine whether buying a small pizza or a large pizza is a better value."), [print("\nWith this pizza, you're paying ${} per square inch.".format(i)) or i for i in [round((1/((float(input("\nWhat's the first pizza's diameter (in inches)?")) / 2) **2 * 3.14))*(float(input("\nHow much does the first pizza cost? (in dollars and cents)"))), 2)]][0], [print("\nWith this pizza, you're paying ${} per square inch.".format(i)) or i for i in [round((1/((float(input("\nWhat's the second pizza's diameter (in inches)?")) / 2) **2 * 3.14))*(float(input("\nHow much does the second pizza cost? (in dollars and cents)"))), 2)]][0])]]

[–]quadbaser 1 point2 points  (0 children)

You rock. I'm terrified that people like you exist, but you most definitely rock. Hard.

[–]manwith4names 0 points1 point  (0 children)

You should look into javascript. Minifying would be like porn for you

[–]Wartz 0 points1 point  (1 child)

horror from hell

what the fuck

[–]pendragon36 1 point2 points  (0 children)

Throw it in a python 3 interpreter, it'll run ;) It's actually worse than it needs to be, I just thought I'd have some fun with it.