Python Maze One-Liner
There are many beautiful pieces of code in the world. One is the maze generation algorithm in
Commodore 64 BASIC that goes
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
. As far as I
can tell, BASIC's popularity
has past the torch to Python, so I offer a Pythonic interpretation to inspire:
python -c 'import math,os,random as r;print(*r.choices(("╱","╲"),k=math.prod(os.get_terminal_size())),sep="",end="");input()'
╱╱╲╲╱╲╲╱╲╲╲╱╲╱╲╱╱╲╲╱╱╱╱╲╱╱╲╲╱╱╲╲╱╱╱╱╲╱╲╲╱╲╲╱ ╱╱╲╲╱╲╲╱╲╲╲╱╲╱╲╱╱╲╲╱╱╱╱╲╱╱╲╲╱╱╲╲╱╱╱╱╲╱╲╲╱╲╲╱ ╱╱╲╲╲╱╲╱╲╱╲╱╲╱╲╲╲╲╲╱╲╱╲╲╱╲╲╲╲╱╲╱╲╱╱╱╲╲╱╱╲╲╱╲ ╱╲╲╲╱╱╱╲╱╲╱╲╱╱╲╱╱╱╲╲╱╲╱╱╱╱╱╱╲╲╱╲╲╲╱╲╲╲╲╲╲╱╲╲ ╱╱╱╲╲╱╱╱╱╱╲╱╲╲╲╱╲╱╱╲╱╲╲╱╱╱╱╱╱╲╱╱╱╱╱╱╲╲╲╱╲╱╱╱ ╲╱╱╱╲╲╱╲╲╲╲╱╱╲╱╱╱╲╲╱╲╲╱╱╱╱╱╱╲╱╲╱╲╱╱╲╲╱╱╲╲╲╱╱ ╲╱╲╱╲╲╲╲╲╱╲╱╱╱╲╱╱╲╲╱╱╲╲╱╱╱╱╲╱╲╱╱╱╲╱╲╲╱╱╱╱╲╱╱ ╱╲╱╱╱╱╲╱╱╲╱╱╲╲╲╲╱╲╱╲╱╱╲╱╲╱╱╱╲╲╲╱╲╲╱╲╲╱╲╲╱╲╱╱ ╲╲╱╱╱╱╲╱╲╲╱╱╲╱╲╱╲╲╱╲╲╲╱╲╱╲╱╱╱╲╱╱╲╱╱╲╲╲╲╱╲╲╱╲ ╱╲╱╱╱╱╱╱╱╲╱╱╲╱╱╱╲╲╱╲╱╱╱╲╱╱╲╲╱╲╲╲╲╲╲╲╱╲╱╲╲╲╱╱ ╱╱╱╲╲╱╱╲╲╱╲╱╱╲╱╱╲╲╱╱╱╱╲╲╱╱╲╲╲╱╲╱╱╱╲╲╱╱╲╲╱╲╱╱ ╱╲╲╱╱╲╲╲╱╱╱╲╲╱╱╱╱╲╲╱╱╱╲╱╱╱╲╲╲╲╱╲╱╱╱╱╱╲╲╲╲╲╱╲ ╱╱╲╲╱╱╱╲╲╲╲╲╲╲╱╲╲╱╲╱╲╱╲╱╲╱╲╱╱╲╱╲╲╱╱╲╱╱╲╱╲╲╲╱ ╲╲╲╱╲╲╲╲╲╲╲╲╲╱╱╱╱╱╲╲╲╲╲╲╱╱╱╱╲╱╲╱╲╲╱╲╲╱╲╱╱╲╱╲ ╱╲╲╱╲╱╱╱╱╲╱╲╱╱╱╲╱╱╱╲╲╱╲╱╲╲╱╲╱╲╲╲╱╲╲╱╱╲╱╲╱╱╲╱ ╲╲╲╲╱╱╱╲╱╱╱╱╱╲╲╱╲╲╱╱╱╲╱╱╱╲╲╲╱╲╱╲╱╱╲╱╲╱╲╲╱╱╱╲ ╲╲╲╲╱╱╱╱╱╲╲╲╲╲╲╱╲╱╱╲╲╱╱╲╱╲╱╱╲╱╱╱╲╲╱╲╱╱╱╱╲╲╲╲ ╲╲╱╲╲╲╱╲╲╲╲╲╱╲╲╱╲╲╱╲╲╱╲╲╱╲╱╱╱╱╱╱╱╱╲╱╲╱╲╲╱╲╲╲ ╱╱╲╲╲╲╱╱╲╱╲╲╲╲╱╲╱╱╱╱╱╲╲╱╲╲╱╲╲╲╲╲╲╲╱╱╱╲╱╲╲╱╱╲ ╲╲╱╱╱╱╲╲╱╲╱╲╱╲╲╲╲╱╱╲╲╱╱╲╱╱╲╲╲╱╱╲╲╲╲╲╲╱╲╱╱╱╲╲ ╱╲╱╲╱╱╲╲╲╲╲╲╱╱╲╲╱╱╱╲╲╱╱╱╲╱╱╲╱╲╱╲╲╲╲╲╲╱╲╲╲╱╲╱ ╲╱╲╲╱╲╲╱╲╱╲╲╱╲╲╱╱╱╲╱╱╲╲╱╱╲╱╱╲╱╲╲╱╲╱╲╱╲╲╲╱╱╱╲