Live data from Hacker News

A single line of Basic sends readers into a labyrinth

slate.com

11–20 of 91 posts

Re: A single line of Basic sends readers into a labyrinth

#11
post #9

The article seems to be a a lot of hyperbole without much substance. The code itself is simple. CHR$(205.5 + RND(1)) becomes CHR$(205) or CHR$(206) depending on the random number. 205 generates a \ , and 206 generates a /.

10 PRINT MID$("/\",1.5+RND(1),1);:GOTO 10 Run it on another old-school computer, like an Apple II, and you won’t get the same transfixing result, for details that have to do with the Commodore 64’s character set, called PETSCII.

Is it the same as this C snippet?

  main() { while (1) printf("%c", rand()%2 ? '/' : '\\'); }
Edit: Golfed my original snippet down, then put back original after mmphosis's identical translation.

Re: A single line of Basic sends readers into a labyrinth

#14
post #9

Earlier quoted context omitted.

10 PRINT MID$("/\",1.5+RND(1),1);:GOTO 10 Run it on another old-school computer, like an Apple II, and you won’t get the same transfixing result, for details that have to do with the Commodore 64’s character set, called PETSCII.

Is it the same as this C snippet? main() { while (1) printf("%c", rand()%2 ? '/' : '\\'); } Edit: Golfed my original snippet down, then put back original after mmphosis's identical translation.

yes.

  #include 
  main() { for(;;) printf(rand()%2 ? "/" : "\\"); }

Re: A single line of Basic sends readers into a labyrinth

#15
If you have a machine with a UTF-8 terminal and a recent-ish Perl (tested on Perl 5.10 + Mac OS X 10.6), you can play along at home by running:

    perl -e '$ |= 1; binmode(STDOUT, ":utf8"); while (1) { print chr(9585.5 + rand()); select(undef, undef, undef, 0.01); }'

Re: A single line of Basic sends readers into a labyrinth

#16
post #10

A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327

Beautiful: http://i.imgur.com/tsFR9.png

I can't believe I've programmed for 15 years without knowing about this.

Re: A single line of Basic sends readers into a labyrinth

#18
post #10

A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327

PowerShell for those on Windows:

for (;;) { write-host -n (get-random ╱,╲) }

Obviously this requires a font supporting those characters. MS Mincho seems to serve well: http://www.microsoft.com/typography/fonts/font.aspx?FMID=206

Re: A single line of Basic sends readers into a labyrinth

#19

Just to be clear...it doesn't generate a labyrinth. It generates something that looks like a labyrinth, but isn't one. It's just random forward and backward slashes.

The device you're on doesn't generate text. It looks like text, but it's really just red, green and blue dots.
Post reply on HN