Note that there are some explanatory texts on larger screens.

plurals
  1. POBash Version of C64 Code Art: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
    primarykey
    data
    text
    <p>I picked up a copy of the book <strong>10 PRINT CHR$(205.5+RND(1)); : GOTO 10</strong></p> <ul> <li><a href="http://rads.stackoverflow.com/amzn/click/0262018462" rel="nofollow">http://www.amazon.com/10-PRINT-CHR-205-5-RND/dp/0262018462</a></li> </ul> <p>This book discusses the art produced by the single line of Commodore 64 BASIC:</p> <pre><code>10 PRINT CHR$(205.5+RND(1)); : GOTO 10 </code></pre> <hr> <p>This just repeatedly prints randomly character 205 or 206 to the screen from the PETSCII set:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/PETSCII" rel="nofollow">http://en.wikipedia.org/wiki/PETSCII</a></li> <li><a href="https://vimeo.com/26472518" rel="nofollow">https://vimeo.com/26472518</a></li> </ul> <p>I'm not sure why the original uses the characters 205 and 206 instead of the identical 109 and 110. Also, I prefer to add a clear at the beginning. This is what I usually type into the C64:</p> <pre><code>1?CHR$(147) 2?CHR$(109.5+RND(1));:GOTO2 RUN </code></pre> <p>You can try this all for yourself in an emulator, such as this one using Flash or JavaScript:</p> <ul> <li><a href="http://codeazur.com.br/stuff/fc64_final/" rel="nofollow">http://codeazur.com.br/stuff/fc64_final/</a></li> <li><p><a href="http://www.kingsquare.nl/jsc64" rel="nofollow">http://www.kingsquare.nl/jsc64</a></p> <p>When inputting the above code into the emulators listed, you'll need to realize that </p> <ul> <li>( is *</li> <li>) is (</li> <li>+ is ]</li> </ul></li> </ul> <hr> <p>I decided it would be amusing to write a bash line to do something similar.</p> <p>I currently have:</p> <pre><code>clear; while :; do [ $(($RANDOM%2)) -eq 0 ] &amp;&amp; (printf "\\") || (printf "/"); done; </code></pre> <p>Two questions:</p> <ol> <li>Any suggestions for making this more concise? </li> <li>Any suggestions for a better output character? The forward and backward slash are not nearly as beautiful since their points don't line up. The characters used from PETSCII are special characters, not slashes. I didn't see anything in ASCII that could work as well, but maybe you can suggest a way to pull in a character from UTF-8 or something else?</li> </ol> <hr> <p><strong>Best ANSWERS So Far</strong></p> <p>Shortest for bash (40 characters):</p> <pre><code>yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash </code></pre> <p>Here is a short one for zsh (53 characters):</p> <pre><code>c=(╱ ╲);clear;while :;do printf ${c[RANDOM%2+1]};done </code></pre> <p>Here is an alias I like to put in my .bashrc or .profile</p> <pre><code>alias art='c=(╱ ╲);while :;do printf "%s" ${c[RANDOM%2]};done' </code></pre> <p>Funny comparing this to the shortest I can do for C64 BASIC (23 characters):</p> <pre><code>1?C_(109.5+R_(1));:G_1 </code></pre> <p>The underscores are shift+H, shift+N, and shift+O respectively. I can't paste the character here since they are specific to PETSCII. Also, the C64 output looks prettier ;)</p> <p>You can read about the C64 BASIC abbreviations here:</p> <ul> <li><a href="http://www.commodore.ca/manuals/c64_programmers_reference/c64-programmers_reference_guide-02-basic_language_vocabulary.pdf" rel="nofollow">http://www.commodore.ca/manuals/c64_programmers_reference/c64-programmers_reference_guide-02-basic_language_vocabulary.pdf</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload