Skip to content

Instantly share code, notes, and snippets.

@ankr
Created November 14, 2013 10:53
Show Gist options
  • Save ankr/7464893 to your computer and use it in GitHub Desktop.
Save ankr/7464893 to your computer and use it in GitHub Desktop.
function greet() {
return brainfuck('[-]>[-]<>++++++++++[<++++++++++>-]<++++.---.>+++[<+++>-]<--..+++.>+++++++++[<--------->-]<++.>+++++++++[<+++++++++>-]<++++++.>+++[<--->-]<+.+++.>++[<-->-]<--.>+++[<--->-]<+.>++++++++[<-------->-]<---.');
}
function brainfuck (i) {
var d = [], o = [], p = 0, c = 0, l = i.length;
while (c !== l) {
!d[p] && (d[p] = 0);
switch (i[c]) {
case '<' : p--; break;
case '>' : p++; break;
case '-' : d[p]--; break;
case '+' : d[p]++; break;
case '[' : while (d[p] === 0 && i[++c] !== ']'); break;
case ']' : while (d[p] !== 0 && i[--c] !== '['); break;
case '.' : o.push(String.fromCharCode(d[p])); break;
}
c++;
}
return o.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment