#MonthOfCode - Day 27: pattern

My entry for the 27th day of the month of code. The theme for today is: pattern.

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

Everything is nicely aligned on my system with the default monospace font but I’ve not tested it on other systems.

Code after the break.

pattern.jsview raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
document.addEventListener('DOMContentLoaded', function() {

var $el = $('#moc-27');
var str = '';

function PRINT(c) {
str += c;
}

function RND() {
return Math.random();
}

function CHR$(n) {
// PETSCII to ASCII
n = Math.floor(n);
return n === 205 ? '/' : '\\';
}

var i = 1984; // not on purpose

while (i--) {
// 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
PRINT(CHR$(205.5+RND(1)));
}

$el.text(str);
});