Hidden stereogram message
TeX 212
I am using a typesetting system, not ASCII. The column width can be changed by changing 90pt
in the fourth line, but I don't know if that's enough to qualify for the 50 bytes discount. The distance between the two copies of the text can be changed by changing the 9pt
, also in the fourth line. The code can probably be made shorter. One can replace each newline by a single space, but not remove them completely.
\let\e\expandafter\read5to\t\read5to\.\def\a#1
{\def\~##1#1##2\a{\def\t{##1\hbox{\
#1\~{}}##2}\a}\e\~\t\a}\e\a\.{}\shipout\hbox
spread9pt{\hsize90pt\fontdimen3\font\hsize\vbox{\t}\
\let\~\ \def\ {}\vbox{\t}}\end.
After calling tex filename.tex
in the terminal, the user is prompted to give the main text, then prompted again for a list of words to shift. No empty line in between. The (space-separated) list of words given in the second line should appear exactly as it is in the main text (punctuation is treated just like a letter would be, only spaces delimit words).
Javascript 391 (441 - 50)
(My first code golf)
k=' ';Q='length';A=prompt().split(k);S=prompt().split(k);i=-1;M=25;L=[[]];j=0;R='';while(i++<A[Q]-1){if((j+A[i][Q])<M){if(S.indexOf(A[i])>-1){A[i]=(j?k+k:k)+A[i]}L[L[Q]-1].push(A[i]);j+=A[i][Q]+1}else{j=0;i--;L.push([])}}for(i=0;i<L[Q]-1;P(L[i++].join(C))){C=k;while(L[i].join(C+k)[Q]<M){C+=k}}P(L[i].join(k)+k);function P(a){while(a[Q]<M){a=a.replace(k,k+k)}R+=a;for(c in S){a=a.split(k+k+S[c]).join(k+S[c]+k)}R+=k+k+a+'\n'}console.log(R);
Result
In a little district In a little district
west of Washington west of Washington
Square the streets have Square the streets have
run crazy and broken run crazy and broken
themselves into small themselves into small
strips called 'places'. strips called 'places'.
These 'places' make These 'places' make
strange angles and strange angles and
curves. One Street curves. One Street
crosses itself a time or crosses itself a time or
two. An artist once two. An artist once
discovered a valuable discovered a valuable
possibility in this possibility in this
street. Suppose a street. Suppose a
collector with a bill collector with a bill
for paints, paper and for paints , paper and
canvas should, in canvas should, in
traversing this route, traversing this route,
suddenly meet himself suddenly meet himself
coming back, without a coming back, without a
cent having been paid on cent having been paid on
account! account!
Long code:
var arr = "In a little district west of Washington Square the streets have run crazy and broken themselves into small strips called 'places'. These 'places' make strange angles and curves. One Street crosses itself a time or two. An artist once discovered a valuable possibility in this street. Suppose a collector with a bill for paints, paper and canvas should, in traversing this route, suddenly meet himself coming back, without a cent having been paid on account!".split(' ');
var secret = "Washington paints himself".split(' ');
var i = -1;
var MAX_WIDTH = 25;
var lines = [[]];
var _l = 0;
var result = '';
while (i++ < arr.length - 1) {
if ((_l + arr[i].length) < MAX_WIDTH) {
if (secret.indexOf(arr[i]) > -1) {arr[i] = (_l?' ':' ') + arr[i]}
lines[lines.length - 1].push(arr[i]);
_l += arr[i].length + 1;
} else {
_l = 0;
i--;
lines.push([]);
}
}
for (var i = 0; i < lines.length - 1; putText(lines[i++].join(chars))) {
// Align text
var chars = ' ';
while (lines[i].join(chars + ' ').length < MAX_WIDTH) {
chars += ' ';
}
}
putText(lines[i].join(' ') + ' ');
function putText(line) {
while (line.length < MAX_WIDTH) {
line = line.replace(' ', ' ');
}
// Make the illusion
result += line;
for (var val in secret) {
line = line.split(' '+secret[val]).join(' ' + secret[val] + ' ');
}
result += (' ' + line) + '\n';
}
console.log(result);
Javascript 493 (minimum expectations)
g=" ";l=prompt().split(g);r=l.slice();m=prompt().split(g);f=[];s=f.slice();w=0;n=0;a="";for(i=0;i<l.length;i++){if(l[i]==m[0]){m.shift();l[i]=g+r[i];r[i]+=g;}if(l[i].length+1>w)w=l[i].length+1;}while(l.length){f[f.length]="";s[s.length]="";while(l.length&&f[f.length-1].length+l[0].length<w){f[f.length-1]+=l[0]+g;s[s.length-1]+=r[0]+g;l.shift();r.shift();}f[f.length-1]+=g.repeat(w-f[f.length-1].length);}console.log(f,s);while(f.length){a+=f[0]+s[0]+"\n";f.shift();s.shift();}console.log(a);
This code sets up two arrays of lines (left and right), arranges them in a string and prints to f12
console.
This is just a minimum answer, not intended to win.