<s>
Malbolge	B-Language
(	O
)	O
is	O
a	O
public	O
domain	O
esoteric	O
programming	O
language	O
invented	O
by	O
Ben	O
Olmstead	O
in	O
1998	O
,	O
named	O
after	O
the	O
eighth	O
circle	O
of	O
hell	O
in	O
Dante	O
's	O
Inferno	O
,	O
the	O
Malebolge	O
.	O
</s>
<s>
It	O
builds	O
on	O
the	O
difficulty	O
of	O
earlier	O
challenging	O
esoteric	O
languages	O
(	O
such	O
as	O
Brainfuck	B-Language
and	O
Befunge	B-Language
)	O
,	O
but	O
takes	O
this	O
aspect	O
to	O
the	O
extreme	O
,	O
playing	O
on	O
the	O
entangled	O
histories	O
of	O
computer	O
science	O
and	O
encryption	O
.	O
</s>
<s>
Despite	O
this	O
design	O
,	O
it	O
is	O
possible	O
to	O
write	O
useful	O
Malbolge	B-Language
programs	O
.	O
</s>
<s>
Malbolge	B-Language
was	O
very	O
difficult	O
to	O
understand	O
when	O
it	O
arrived	O
.	O
</s>
<s>
It	O
took	O
two	O
years	O
for	O
the	O
first	O
Malbolge	B-Language
program	O
to	O
appear	O
.	O
</s>
<s>
The	O
author	O
himself	O
has	O
never	O
written	O
a	O
Malbolge	B-Language
program	O
.	O
</s>
<s>
The	O
first	O
program	O
was	O
not	O
written	O
by	O
a	O
human	O
being	O
;	O
it	O
was	O
generated	O
by	O
a	O
beam	B-Algorithm
search	I-Algorithm
algorithm	O
designed	O
by	O
Andrew	O
Cooke	O
and	O
implemented	O
in	O
Lisp	B-Language
.	O
</s>
<s>
Later	O
,	O
Lou	O
Scheffer	O
posted	O
a	O
cryptanalysis	O
of	O
Malbolge	B-Language
and	O
provided	O
a	O
program	O
to	O
copy	O
its	O
input	O
to	O
its	O
output	O
.	O
</s>
<s>
He	O
also	O
saved	O
the	O
original	O
interpreter	B-Application
and	O
specification	O
after	O
the	O
original	O
site	O
stopped	O
functioning	O
,	O
and	O
offered	O
a	O
general	O
strategy	O
of	O
writing	O
programs	O
in	O
Malbolge	B-Language
as	O
well	O
as	O
some	O
thoughts	O
on	O
its	O
Turing	B-Algorithm
completeness	I-Algorithm
.	O
</s>
<s>
Olmstead	O
believed	O
Malbolge	B-Language
to	O
be	O
a	O
linear	B-Application
bounded	I-Application
automaton	I-Application
.	O
</s>
<s>
There	O
is	O
a	O
discussion	O
about	O
whether	O
one	O
can	O
implement	O
sensible	O
loops	O
in	O
Malbolge	B-Language
—	O
it	O
took	O
many	O
years	O
before	O
the	O
first	O
non-terminating	O
one	O
was	O
introduced	O
.	O
</s>
<s>
also	O
proposed	O
a	O
guide	O
for	O
programming	O
in	O
Malbolge	B-Language
for	O
the	O
purpose	O
of	O
obfuscation	O
for	O
software	O
protection	O
.	O
</s>
<s>
In	O
2020	O
,	O
GitHub	B-Application
user	O
kspalaiologos	O
made	O
a	O
working	O
Lisp	B-Language
interpreter	B-Application
in	O
Malbolge	B-Language
Unshackled	O
.	O
</s>
<s>
This	O
program	O
reads	O
a	O
string	O
from	O
a	O
user	O
and	O
prints	O
that	O
string	O
,	O
similar	O
to	O
Unix	O
echo	B-Application
.	O
</s>
<s>
Malbolge	B-Language
is	O
machine	B-Language
language	I-Language
for	O
a	O
ternary	B-Algorithm
virtual	B-Architecture
machine	I-Architecture
,	O
the	O
Malbolge	B-Language
interpreter	B-Application
.	O
</s>
<s>
The	O
standard	O
interpreter	B-Application
and	O
the	O
official	O
specification	O
do	O
not	O
match	O
perfectly	O
.	O
</s>
<s>
Malbolge	B-Language
has	O
three	O
registers	B-General_Concept
,	O
a	O
,	O
c	O
,	O
and	O
d	O
.	O
When	O
a	O
program	O
starts	O
,	O
the	O
value	O
of	O
all	O
three	O
registers	B-General_Concept
is	O
zero	O
.	O
</s>
<s>
a	O
stands	O
for	O
'	O
accumulator	O
 '	O
,	O
set	O
to	O
the	O
value	O
written	O
by	O
all	O
write	O
operations	O
on	O
memory	B-Architecture
and	O
used	O
for	O
standard	B-General_Concept
I/O	I-General_Concept
.	O
</s>
<s>
c	O
,	O
the	O
code	O
pointer	O
,	O
is	O
special	O
:	O
it	O
points	B-General_Concept
to	I-General_Concept
the	I-General_Concept
current	I-General_Concept
instruction	I-General_Concept
.	O
</s>
<s>
d	O
can	O
hold	O
a	O
memory	B-Architecture
address	O
;	O
 [ d ] 	O
is	O
register	O
indirect	O
;	O
the	O
value	O
stored	O
at	O
that	O
address	O
.	O
</s>
<s>
The	O
virtual	B-Architecture
machine	I-Architecture
has	O
59,049	O
(	O
310	O
)	O
memory	B-Architecture
locations	O
that	O
can	O
each	O
hold	O
a	O
ten-trit	O
ternary	B-Algorithm
number	I-Algorithm
.	O
</s>
<s>
Each	O
memory	B-Architecture
location	O
has	O
an	O
address	O
from	O
0	O
to	O
59048	O
and	O
can	O
hold	O
a	O
value	O
from	O
0	O
to	O
59048	O
.	O
</s>
<s>
The	O
language	O
uses	O
the	B-Architecture
same	I-Architecture
memory	I-Architecture
space	I-Architecture
for	I-Architecture
both	I-Architecture
data	I-Architecture
and	I-Architecture
instructions	I-Architecture
.	O
</s>
<s>
Before	O
a	O
Malbolge	B-Language
program	O
starts	O
,	O
the	O
first	O
part	O
of	O
memory	B-Architecture
is	O
filled	O
with	O
the	O
program	O
.	O
</s>
<s>
All	O
whitespace	O
in	O
the	O
program	O
is	O
ignored	O
and	O
,	O
to	O
make	O
programming	O
more	O
difficult	O
,	O
everything	O
else	O
in	O
the	O
program	O
must	O
start	O
out	O
as	O
one	O
of	O
the	O
instructions	B-Language
below	O
.	O
</s>
<s>
The	O
rest	O
of	O
memory	B-Architecture
is	O
filled	O
by	O
using	O
the	O
crazy	O
operation	O
(	O
see	O
below	O
)	O
on	O
the	O
previous	O
two	O
addresses	O
( [	O
m ]	O
=	O
crz	O
[	O
m	O
-	O
2 ]	O
,	O
[	O
m	O
-	O
1 ]	O
)	O
.	O
</s>
<s>
Memory	B-Architecture
filled	O
this	O
way	O
will	O
repeat	O
every	O
twelve	O
addresses	O
(	O
the	O
individual	O
ternary	B-Algorithm
digits	O
will	O
repeat	O
every	O
three	O
or	O
four	O
addresses	O
,	O
so	O
a	O
group	O
of	O
ternary	B-Algorithm
digits	O
is	O
guaranteed	O
to	O
repeat	O
every	O
twelve	O
)	O
.	O
</s>
<s>
In	O
2007	O
,	O
Ørjan	O
Johansen	O
created	O
Malbolge	B-Language
Unshackled	O
,	O
a	O
version	O
of	O
Malbolge	B-Language
which	O
does	O
not	O
have	O
the	O
arbitrary	O
memory	B-Architecture
limit	O
.	O
</s>
<s>
The	O
hope	O
was	O
to	O
create	O
a	O
Turing-complete	O
language	O
while	O
keeping	O
as	O
much	O
in	O
the	O
spirit	O
of	O
Malbolge	B-Language
as	O
possible	O
.	O
</s>
<s>
No	O
other	O
rules	O
are	O
changed	O
,	O
and	O
all	O
Malbolge	B-Language
programs	O
that	O
do	O
not	O
reach	O
the	O
memory	B-Architecture
limit	O
are	O
completely	O
functional	O
.	O
</s>
<s>
Malbolge	B-Language
has	O
eight	O
instructions	B-Language
.	O
</s>
<s>
Malbolge	B-Language
figures	O
out	O
which	O
instruction	O
to	O
execute	O
by	O
taking	O
the	O
value	O
[c],	O
adding	O
the	O
value	O
of	O
c	O
to	O
it	O
,	O
and	O
taking	O
the	O
remainder	O
when	O
this	O
is	O
divided	O
by	O
94	O
.	O
</s>
<s>
The	O
final	O
result	O
tells	O
the	O
interpreter	B-Application
what	O
to	O
do	O
:	O
</s>
<s>
+	O
Instructions	B-Language
Value	O
of	O
Instructionrepresented	O
Explanation	O
4	O
Copies	O
the	O
value	O
at	O
 [ d ] 	O
to	O
c	O
.	O
Note	O
that	O
c	O
will	O
still	O
be	O
incremented	O
after	O
execution	O
of	O
this	O
instruction	O
,	O
so	O
the	O
next	B-General_Concept
instruction	I-General_Concept
to	O
be	O
executed	O
will	O
be	O
the	O
one	O
at	O
 [ d ] 	O
+	O
1	O
(	O
modulo	O
59049	O
)	O
.	O
</s>
<s>
5	O
Prints	O
the	O
value	O
of	O
a	O
,	O
as	O
an	O
ASCII	B-Protocol
character	I-Protocol
,	O
to	O
the	O
screen	O
.	O
</s>
<s>
23	O
Inputs	O
a	O
character	O
,	O
as	O
an	O
ASCII	B-Protocol
code	I-Protocol
,	O
into	O
a	O
.	O
Newlines	O
or	O
line	O
feeds	O
are	O
both	O
code	O
10	O
.	O
</s>
<s>
39	O
Rotates	O
the	O
value	O
at	O
 [ d ] 	O
by	O
one	O
ternary	B-Algorithm
digit	O
to	O
the	O
right	O
(	O
0002111112	O
becomes	O
2000211111	O
)	O
.	O
</s>
<s>
81	O
Ends	O
the	O
Malbolge	B-Language
program	O
.	O
</s>
<s>
Right	O
after	O
a	O
jump	O
,	O
Malbolge	B-Language
will	O
encrypt	O
the	O
innocent	O
instruction	O
just	O
prior	O
to	O
the	O
one	O
it	O
jumped	O
to	O
instead	O
.	O
</s>
<s>
Then	O
,	O
the	O
values	O
of	O
both	O
c	O
and	O
d	O
are	O
increased	O
by	O
one	O
and	O
the	O
next	B-General_Concept
instruction	I-General_Concept
is	O
executed	O
.	O
</s>
<s>
For	O
each	O
ternary	B-Algorithm
digit	O
of	O
both	O
inputs	O
,	O
use	O
the	O
following	O
table	O
to	O
get	O
a	O
ternary	B-Algorithm
digit	O
of	O
the	O
result	O
.	O
</s>
<s>
Then	O
,	O
the	O
result	O
is	O
enciphered	B-Algorithm
with	O
one	O
of	O
the	O
following	O
two	O
equivalent	O
methods	O
.	O
</s>
<s>
Store	O
the	O
ASCII	B-Protocol
code	I-Protocol
of	O
the	O
character	O
below	O
it	O
at	O
 [ c ] 	O
.	O
</s>
<s>
Lou	O
Scheffer	O
's	O
cryptanalysis	O
of	O
Malbolge	B-Language
mentions	O
six	O
different	O
cycles	O
in	O
the	O
permutation	B-Algorithm
.	O
</s>
<s>
Lou	O
Scheffer	O
used	O
this	O
idea	O
to	O
create	O
a	O
Malbolge	B-Language
program	O
(	O
included	O
in	O
his	O
cryptanalysis	O
linked	O
below	O
)	O
that	O
repeats	O
anything	O
the	O
user	B-General_Concept
inputs	I-General_Concept
.	O
</s>
<s>
Malbolge	B-Language
is	O
not	O
Turing-complete	O
,	O
due	O
to	O
its	O
memory	B-Architecture
limits	O
.	O
</s>
<s>
Several	O
attempts	O
have	O
been	O
made	O
to	O
create	O
Turing-complete	O
versions	O
of	O
Malbolge	B-Language
:	O
</s>
<s>
Malbolge20	O
is	O
a	O
version	O
of	O
Malbolge	B-Language
with	O
an	O
expanded	O
word-size	O
of	O
20	O
trits	B-Algorithm
,	O
allowing	O
one	O
to	O
write	O
a	O
program	O
with	O
a	O
size	O
of	O
up	O
to	O
~	O
3.4	O
gigabytes	O
.	O
</s>
<s>
Malbolge-T	O
is	O
a	O
theoretical	O
version	O
of	O
Malbolge	B-Language
that	O
resets	O
the	O
input/output	B-General_Concept
stream	O
upon	O
reaching	O
the	O
end	O
,	O
allowing	O
for	O
unbounded	O
programs	O
.	O
</s>
<s>
Malbolge-T	O
would	O
be	O
backward	B-General_Concept
compatible	I-General_Concept
with	O
Malbolge	B-Language
.	O
</s>
<s>
Malbolge	B-Language
Unshackled	O
is	O
a	O
hopefully	O
Turing-complete	O
variation	O
,	O
allowing	O
for	O
programs	O
of	O
any	O
length	O
.	O
</s>
<s>
However	O
,	O
due	O
to	O
command	O
variations	O
to	O
allow	O
for	O
values	O
above	O
257	O
,	O
valid	O
Malbolge	B-Language
programs	O
will	O
not	O
necessarily	O
run	O
correctly	O
in	O
Malbolge	B-Language
Unshackled	O
.	O
</s>
<s>
In	O
the	O
television	O
series	O
Elementary	O
,	O
during	O
the	O
episode	O
"	O
The	O
Leviathan	O
"	O
(	O
season	O
1	O
,	O
episode	O
10	O
)	O
,	O
a	O
clue	O
written	O
on	O
a	O
coffee	O
order	O
is	O
described	O
as	O
having	O
been	O
written	O
in	O
Malbolge	B-Language
.	O
</s>
<s>
In	O
the	O
Leverage	O
:	O
Redemption	O
episode	O
"	O
The	O
Golf	O
Job	O
"	O
(	O
season	O
1	O
,	O
episode	O
12	O
)	O
,	O
an	O
SMS	O
auto-reply	O
reads	O
"	O
Breanna	O
is	O
unavailable	O
Thursday	O
through	O
Sunday	O
or	O
until	O
she	O
masters	O
Malbolge	B-Language
code.	O
"	O
</s>
<s>
In	O
the	O
Billions	O
episode	O
"	O
The	O
Limitless	O
Shit	O
"	O
(	O
season	O
5	O
,	O
episode	O
7	O
)	O
,	O
a	O
programmer	O
analyst	O
at	O
Axe	O
Capital	O
explains	O
that	O
he	O
"	O
...	O
used	O
to	O
dick	O
around	O
with	O
Malbolge	B-Language
,	O
but	O
just	O
for	O
fun.	O
"	O
</s>
