Slashdot Mirror


How Does a Single Line of BASIC Make an Intricate Maze?

JameskPratt writes "This Slate article talks about a single line of code — 10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10 — and how it manages to create a complicated maze without the use of a loop, variables and without very complicated syntax." Now that amazing snippet of code is the basis of a book, and the book is freely downloadable.

8 of 438 comments (clear)

  1. 10 ... : GOTO 10 is a loop by Mneme · · Score: 5, Informative

    it manages to create a complicated maze with out the use of a loop, variables and without very complicate syntax

    It's very cool the way this code draws a maze, but there's obviously a loop there.

    (And it's “without” not “with out”, and “complicated” not “complicate”.)

  2. Re:Without the use of a loop!? by Nutria · · Score: 4, Informative

    That's exactly what I thought... Maybe JameskPratt isn't a very good programmer.

    --
    "I don't know, therefore Aliens" Wafflebox1
  3. Re:Without the use of a loop!? by Anonymous Coward · · Score: 5, Informative

    No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

  4. Reminded me of DataGlyphs by tepples · · Score: 4, Informative

    It's just randomly printing forward and backward slashes, which line up because of the font. It's nifty, but hardly amazing.

    And in fact, it appears Slashdot ran an article on this a decade ago when it was called DataGlyphs.

  5. Re:No loop? by Zero__Kelvin · · Score: 5, Informative

    "Everyone knows that : in BASIC starts a new line."

    Nobody knows that, because it is untrue. The : is a statement separator, not a line seperator. That 10 you see is the line number. Notice that there are no other line numbers. Make an error on either side of the colon and the interpreter will give you the exact same complaint: Syntax error in line 10. You can verify this by looking for the line " In BASIC it's used as a separator between the statements or instructions in a single line." on Wikipedia, or use your Google-Fu to verify it thousands of other ways.

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  6. Re:Without the use of a loop!? by egcagrac0 · · Score: 4, Informative
    #include
    main() { ten: printf("%c", (rand()%2)?47:92); goto ten; }

    The preprocessor include directive is on a separate line, but that's really not part of the program.

  7. Re:Enterprise Java Version by narcc · · Score: 5, Informative

    Plagiarizer. You stole this from reddit -- from the same post linked from Nick Montfort's blog.

    Enterprise Java Version:
    http://www.reddit.com/r/programming/comments/142jix/10_print_chr_2055_rnd_1_goto_10_how_a_single_line/c79elxn

    You shouldn't take credit for the work of others. That +5 funny is a filthy dirty lie.

  8. Re:Without the use of a loop!? by Dan+East · · Score: 5, Informative

    And finally, here's a screenshot in case anyone actually cares what the TI version looks like.

    http://dexsoft.com/slashdot/ti_screenshot.png

    --
    Better known as 318230.