View Full Version : Implementing "10 PRINT CHR$(205.5+RND(1)); : GOTO 10" in Excel & MapPoint

Eric Frost
12-02-2012, 02:51 PM
10 PRINT CHR$(205.5+RND(1)); : GOTO 10 (http://10print.org/) is a new publication by a group of 10 writers who use this one line Commodore Basic program to explore topics in simplicity, randomness, other one-liners, ports to other platforms and other topics in Software Studies.


An article about the publication recently appeared on Slate (http://www.slate.com/articles/technology/books/2012/11/computer_programming_10_print_chr_205_5_rnd_1_goto _10_from_mit_press_reviewed.html) and it was discussed on Slashdot (http://developers.slashdot.org/story/12/12/01/1847244/how-does-a-single-line-of-basic-make-an-intricate-maze).

Although the print book is available for purchase on Amazon (http://www.amazon.com/gp/product/0262018462/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0262018462&linkCode=as2&tag=slatmaga-20), a PDF of the publication is freely downloadable (http://10print.org).

I took it as a challenge to implement this in Excel VBA to render in Excel, and then MapPoint. While it's no longer anything near a one-liner, at least it's no longer a never ending loop.

The code below writes a maze 255 characters high and 100 characters wide onto an Excel worksheet.

Sub CreateMaze()
Dim txt As String
For i = 1 To 255
txt = Slash()
For j = 1 To 99
txt = txt + Slash()
Cells(i, 1) = txt
End Sub

It uses this helper function to randomly pick a backward or forward slash.

Function Slash() As String
Select Case Round(Rnd(1))
Case 0:
Slash = "\"
Case 1:
Slash = "/"
Case Else
End Select
End Function

This is what the output looks like in Excel.

There's room for improvement I'm sure, to get the lines to touch and close, I'm sure there's some better font with symbols, and perhaps there's a way to turn off cell padding in Excel.


Actually, I think the cell borders in Excel allow for diagonal lines, this might actually be the best way to go.

In any case, the Excel macro with code and output are attached and can be downloaded here -- 734.

This being MapForums, as you can imagine, the real purpose of this article is to explore rendering this same thing in MapPoint and discuss the pros/cons of each.

In a follow up to this article, we will look at three different methods to render the maze in MapPoint.

Displaying the slashes and maze in a TextBox.
Using Custom Pushpins to display the slash maze.
Using Lines to depict the slash maze.

Please post below with any questions or comments.