Esoteric Programming
Esoteric Programming
AcoupleofesotericprogramminglanguageslikeBrainf**k,whitespaceisalsoincludedinthecontest
Itwillbeinterestingtodiscusssomefactsaboutthemhere.
Brainf**kinterpreterneglectseverythingexceptthe8symbols"><,.[]+"soabrainf**kprogramcanbe
includedinanyprogramwithincomments.
Itconsistsofonlyeightcommands.
Character Meaning
>
<
+
.
,
[
]
incrementthedatapointer(topointtothenextcelltotheright).
decrementthedatapointer(topointtothenextcelltotheleft).
increment(increasebyone)thebyteatthedatapointer.
decrement(decreasebyone)thebyteatthedatapointer.
outputthevalueofthebyteatthedatapointer.
acceptonebyteofinput,storingitsvalueinthebyteatthedatapointer.
ifthebyteatthedatapointeriszero,theninsteadofmovingtheinstructionpointerforwardtothe
nextcommand,jumpitforwardtothecommandafterthematching]command.
ifthebyteatthedatapointerisnonzero,theninsteadofmovingtheinstructionpointerforwardto
thenextcommand,jumpitbacktothecommandafterthematching[command.
ToknowmoreaboutBrainf**kgotohttp://en.wikipedia.org/wiki/Brainfuck
Example
AbilingualinCandBrainf**kwhichtakesasinputastringoflength5andprintsitsinreverse...
#definebrainfck,>,>,>,>,>,<.<.<.<.<.
#include<stdio.h>
main()
{
inti;
chars[5];
for(i=0;i<5;i++)
s[i]=getchar();
for(i=4;i>1;i)
putchar(s[i]);
putchar('\n');
}
AbilingualinCandBrainf**kwhichtakesasinputa6bitdecimalnumberandprintsitsbinaryequivalentis
/*+++>>,>,>++++++++[<<>>]<<[>++++++++++<]>[>>>+>+<<<<]>>>[<<<+>>>]<<<[[>+>]<<]<[>>]>>[
<+>>+<]>[>><<]>++++++++[>++++++<]>[>>>>>>>>+<<<<<<<<][]<<<<[<+>>>>>+<<<<]<[>+<]>[[>+>]<<]<[>>]
>>[<+>>+<]>[>><<]>++++++++[>++++++<]>[>>>>>>>+<<<<<<<][]<<<<[<+>>>>>+<<<<]<[>+<]>[[>+>]<<]<[>>]
>>[<+>>+<]>[>><<]>++++++++[>++++++<]>[>>>>>>+<<<<<<][]<<<<[<+>>>>>+<<<<]<[>+<]>[[>+>]<<]<[>>]
>>[<+>>+<]>[>><<]>++++++++[>++++++<]>[>>>>>+<<<<<][]<<<<[<+>>>>>+<<<<]<[>+<]>[[>+>]<<]<[>>]>>[
<+>>+<]>[>><<]>++++++++[>++++++<]>[>>>>+<<<<][]<<<<[<+>>>>>+<<<<]<[>+<]>[[>+>]<<]<[>>]>>[
<+>>+<]>[>><<]>++++++++[>++++++<]>[>>>+<<<][]<<<<[<+>>>>>+<<<<]<[>+<]>>>>>>>>.>.>.>.>.>.>>>>>*/
#include<stdio.h>
#include<math.h>
main()
{
inti,k;
scanf("%d",&i);
for(k=5;k>1;k)
{
if(i>=pow(2,k))
{
putchar('1');
i=pow(2,k);
}
else
putchar('0');
}
}
NextistheesotericprogramminglanguageWhiteSpacewhichneglectseverythingexceptspace,tabandenter.
Agoodtutorialaboutthisisavailableathttp://compsoc.dur.ac.uk/whitespace/tutorial.php
Asyoumayseeitsveryeasytoincludeawhitespaceprograminapolyglottoincreasethecountbutitsverytough
t
towriteone.