← All lessons

LESSON 11 OF 13

THE FAMOUS ONE-LINER

10 PRINT CHR$(205.5+RND(1)); : GOTO 10

CHR$RNDPETSCII graphics

This single line has had a whole book written about it. CHR$ ignores anything after the decimal point, so 205.5 plus a random number between 0 and 1 is either 205 or 206 — the two diagonal line characters in the graphics set. Print them endlessly and a maze grows down the screen.

It is the purest example of what the C64 character set was for: the graphics are characters, so a maze is just text.

Try other pairs of codes. 233 and 223 give triangles; 165 and 167 give vertical bars; 102 is a checkerboard.

LESSON 113 lines

Type with the keyboard under the screen, or tap the blue screen to use your phone's own keyboard. While a program runs, keys go to INPUT and GET. When it says READY., type a line and press RETURN to run it straight away.