Python One-Liners: Higher or Lower
MarcusWeinberger (583)

Here is an example of the game "higher or lower" written in a single line. I've used a variety of tricks to make this work in a single line such as:

  • globals().setattr to let me set variables inside a lambda function
  • (globals().setattr("guess",x) or globals ()["guess"]) to use the := operator in python 3.7, the := operator only being introduced in python 3.8 which repl.it has yet to upgrade to
  • for i in iter(int, 1) instead of a while loop which would require more than one line

And some others. If you'd like, share some of your other one-line programs because I'm interested in them at the moment.

You are viewing a single comment. View All
MarcusWeinberger (583)

@mwilki7 damn, that's impressive. I don't really know JS so there's a lot that I dont understand but you certainly beat me length-wise! Well done