My friend challenged me to find the shortest solution to a certain Leetcode-style problem in Python. They were generous enough to let me use whitespac

Any Python program fits in 24 characters* | purplesyringa's blog

submited by
Style Pass
2024-11-18 00:30:05

My friend challenged me to find the shortest solution to a certain Leetcode-style problem in Python. They were generous enough to let me use whitespace for free, so that the code stays readable. So that’s exactly what we’ll abuse to encode any Python program in 24 bytes, ignoring whitespace.This post originally stated that 30 characters are always enough. Since then, commandz and xnor from the Code Golf Discord server have devised a better solution, reaching 24 bytes. After a few minor modifications, it satisfies the requirements of this problem, so I publish it here too.

This post originally stated that 30 characters are always enough. Since then, commandz and xnor from the Code Golf Discord server have devised a better solution, reaching 24 bytes. After a few minor modifications, it satisfies the requirements of this problem, so I publish it here too.

Bits We can encode arbitrary data in a string by only using whitespace. For example, we could encode 0 bits as spaces and 1 bits as tabs. Now you just have to decode this.

Leave a Comment