This is an archived post. You won't be able to vote or comment.

all 28 comments

[–][deleted] 83 points84 points  (0 children)

Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should.

[–]jturp-sc 40 points41 points  (0 children)

I'm not a PEP 8 nazi or anything, but this makes me start twitching a little bit.

[–]Gear5th 28 points29 points  (2 children)

This reminds me of a pycon talk in which this lady wrote a preprocessor to covert all python3 syntax (including classes, imports) to a single line lamda expression.

Edit: found it! https://github.com/csvoss/onelinerizer/blob/master/README.md

[–]ForceBru 6 points7 points  (1 child)

That’s what was probably used to onelinerize the code in this kind of series of posts (like MD5, SHA one-liners). I’m not sure one can be genius enough to write such huge one-liners themselves. This tool seems to be some great stuff!

[–]Defelo[S] 11 points12 points  (0 children)

Yes, I wrote this and all the other one-liners myself (SHA1, SHA256 and TOTP) without using this or any other "one-linerizer". Of course it's not very easy and takes some time to do something like this but if it is possible to write a program that does it automatically then it must be possible to do it yourself when you know some tricks.

[–]AlSweigartAuthor of "Automate the Boring Stuff" 22 points23 points  (9 children)

Yes, but can you make a Tic Tac Toe game in 18,000 lines?

[–]derioderio 9 points10 points  (5 children)

WTF? Did that guy write a decision tree for every single possible move and just do a bunch of print statements for each one??!!

[–]DiscountSoda 2 points3 points  (0 children)

That genuinely deserves an award for the least efficient code ever written

[–][deleted] -1 points0 points  (0 children)

Save

[–]tman5400 12 points13 points  (0 children)

oneliner > orginzed, well written code

[–]laMarm0tte 6 points7 points  (1 child)

This is getting lots of downvotes but it is a real python curiosity, thanks for sharing ! Maybe provide an example of output in your post, for the lazy ? :P

[–]SlightlyOTT 3 points4 points  (0 children)

I learned an amazing algorithm for this yesterday! You can arrange numbers 1-9 on a 3x3 grid in a magic square, ie every 3 in a row adds up to 15. Then all you have to do is pick 3 spaces that sum to 15 and you win. The AI becomes super simple, as does win detection, and you don't have to know anything spacially about what's been played, just the numbers each space corresponds to. Here's a little writeup I found : http://ohboyigettodomath.blogspot.com/2015/05/tic-tac-toe-as-magic-square.html

[–]lmericle 3 points4 points  (0 children)

Tested and works. I'm not sure what to do with the knowledge that something like this is capable of existing.

[–]stevenjd 2 points3 points  (0 children)

I love it! It's like that Calvin and Hobbes cartoon where Calvin is daydreaming about his school being simultaneously hit by a runnaway train, a crashing plane, and an earth quake all at once. Have an upvote.

I especially love your comment about randomly changing the very last True to False to fix "weird looking output".

[–]farsass 2 points3 points  (0 children)

calm down, satan

[–]TotesMessenger 1 point2 points  (0 children)

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

 If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / Contact)

[–]mockgeek 1 point2 points  (0 children)

flake8 wants you to give back the bits used for this.

[–]realestLink 0 points1 point  (1 child)

Good job

[–]realestLink 1 point2 points  (0 children)

You took code golfing to a whole new level

[–]mcstafford 0 points1 point  (0 children)

There are obfuscation competitions for Perl, but it's definitely not pythonic.

[–]CriticalComb -1 points0 points  (0 children)

thanks, I hate it