Unibrain
Unibrain is a joke esoteric programming language created by User:Robert de Bath. It is identical to Brainfuck, except that the instructions are changed to repetitive codes each of which are interpreted as a form of unary number. As such, it is an infinite subset of the TrivialBrainfuckSubstitution family of programming languages. Note there are 40320 related subsets where the brainfuck commands are reordered.
Commands
Brainfuck | Unibrain | Description |
---|---|---|
> | Baa | Move the pointer to the right |
< | BaaBaa | Move the pointer to the left |
+ | BaaBaaBaa | Increment the memory cell under the pointer |
- | BaaBaaBaaBaa | Decrement the memory cell under the pointer |
. | BaaBaaBaaBaaBaa | Output the character signified by the cell at the pointer |
, | BaaBaaBaaBaaBaaBaa | Input a character and store it in the cell at the pointer |
[ | BaaBaaBaaBaaBaaBaaBaa | Loop Start: Jump past the matching loop ending if the cell under the pointer is 0 |
] | BaaBaaBaaBaaBaaBaaBaaBaa | Loop ending: Jump back just after the matching loop start |
Each of the Baa
codes represents any case insensitive ASCII alphanumeric string the string must be concatenated the specified number of times (1..8) to represent a command. If it's possible to divide the string in more than one way (eg: 1, 2, 4 and 8) the largest number must be used. For unibrain the code used does not have to be the same from command to command.
Hello World Example
n XXX o XXX x XXX XXX w XXX xxx DevelopersDevelopersDevelopersDevelopersDevelopersDevelopersDevelopers Aha DevelopersDevelopersDevelopersDevelopersDevelopersDevelopersDevelopers BaaBaaBaaBaa baa XXX XXX XXX XXX BaaBaa BaaBaa xxx XXX XXX h oooooooo BaaBaa BaaBaa oooooooo l XXXX WOWWOWWOWWOW XXXX WOWWOWWOWWOW 11111 5 2 xxx 22222 XXX XXX XXX XXX xxx XXX XXX 33333 44444 XXX XXX xxx 55555 9 66666 BaaBaa BaaBaa BaaBaa XXX XXX XXX XXX xxx XXX XXX XXX XXX xxx XXX XXX XXX XXX xxx 77777 j 1 88888 XXX XXX XXX 99999 XXXX WOWWOWWOWWOW XXXX WOWWOWWOWWOW XXXX WOWWOWWOWWOW 00000 XXXX WOWWOWWOWWOW XXXX WOWWOWWOWWOW XXXX WOWWOWWOWWOW XXXX WOWWOWWOWWOW 99999 c XXX 77777 w XXX XXX 66666
Convert Unibrain to Brainfuck.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> void do_file(FILE * fd); char *bf = "><+-.,[]"; int bflen = 8; /* char * bf = "+-><,.[]"; \* Order for commands in "Developers" language */ int main(int argc, char ** argv) { FILE * f; if (argc > 1 && strncmp(argv[1], "-b", 2) == 0) { bf = argv[1] + 2; bflen = strlen(bf); argv++; argc--; } f = argv[1]&&strcmp(argv[1],"-")?fopen(argv[1],"r"):stdin; if (!f) { perror(argv[1]); exit(1); } do_file(f); return 0; } void do_file(FILE * fd) { static char * word; static int maxp; int col = 0; int p = 0, ch; do { ch = getc(fd); if (!isascii(ch)) ; else if (isspace(ch)) { if (p) { int i; word[p] = 0; for(i=bflen; i>0; i--) { int found = 1; int s = p/i; int j; if (s*i != p) continue; for(j=0; j<p; j++) { if (word[j] != word[j%s]) { found = 0; break; } } if (found) { putchar(bf[i-1]); if ((col=((col+1)%72)) == 0) putchar('\n'); break; } } } p = 0; } else if (isalnum(ch)) { if (isupper(ch)) ch += 'a'-'A'; if (p+2>maxp) { word = realloc(word, maxp += 256); } word[p++] = ch; } } while (ch != EOF); if(col) putchar('\n'); }
Related Languages
- Developers The language inspired by Steve Ballmer.
- BaaBaa The language for Sheeple.