A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
A single line of Basic sends readers into a labyrinth
31–40 of 91 posts
Re: A single line of Basic sends readers into a labyrinth
#32Re: A single line of Basic sends readers into a labyrinth
#33var r = 0; function go(){setTimeout('document.write(r++ % 80 ? Math.round(Math.random()) ? "\\\\" : "/" : "
"); go()', 100)}; go();
This was actually a lot more difficult for me to write than I thought it would be. `document.write` blocks and also a browser doesn't wrap by default, hence the r variable.
This will, of course, nuke any page you happen to run it on. :)
P.S. Why is code formatted so badly on HN these days? Until that's fixed I'll just use normal formatting.
Re: A single line of Basic sends readers into a labyrinth
#34A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
Not for me. "syntax error near unexpected token ';' == no printf
Re: A single line of Basic sends readers into a labyrinth
#35Earlier quoted context omitted.
This makes it slower, so it's more pleasant to watch: echo 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'|ruby
Why piping to ruby? You have the -e operator for that: ruby -e 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'
ruby -e 'print %W{\u2571 \u2572}.sample while sleep 1e-3'
(Updated: Made 3 chars shorter.)And a shorter, but cheats, version:
yes|ruby -pe'$_=%W{\u2571 \u2572}.sample;sleep 1e-3'
My favorite overall balance of readability and shortness though is: ruby -e 'print %w{╱ ╲}.sample while sleep 0.01'Re: A single line of Basic sends readers into a labyrinth
#36JavaScript (in a browser): var r = 0; function go(){setTimeout('document.write(r++ % 80 ? Math.round(Math.random()) ? "\\\\" : "/" : " "); go()', 100)}; go(); This was actually a lot more difficult for me to write than I thought it would be. `document.write` blocks and also a browser doesn't wrap by default, hence the r variable. This will, of course, nuke any page you happen to run it on. :) P.S. Why is code formatt…
Re: A single line of Basic sends readers into a labyrinth
#37For instance, some spaces are clearly enclosed. i.e., there is a finite border outside which you cannot escape. Some paths seem to run on for a very long time. Are all paths enclosed? If so, given a random point on a randomly generated maze, what is the average area of an enclosure?
Re: A single line of Basic sends readers into a labyrinth
#38Earlier quoted context omitted.
The article links to the book's (free) download page: http://10print.org
Thanks, I wonder who is the idiot who downvotes an honest question. Still, I would pay $9.99 for mobi or epub. PDF is inconvenient for the Kindle and the iPad. Converting with Calibre is a chore, and rarely yields good results.