# Malbolge

Paradigm Esoteric, Imperative, Scalar,Value-level Ben Olmstead 1998 Untyped .mal, .mb None Brainfuck, INTERCAL ( Tri-INTERCAL), Befunge

Malbolge - is a public domain esoteric programming language invented by Ben Olmstead in 1998, named after the eighth circle of hell in Dante's Inferno, the Malebolge.

Malbolge was specifically designed to be almost impossible to use, via a counter-intuitive 'crazy operation', base-three arithmetic and self-altering code.[1] It builds on the difficulty of earlier, challenging esolangs (such as Brainfuck and Befunge), but takes this aspect to the extreme, playing on the entangled histories of computer science and encryption. Weaknesses in the design have been found that make it possible (though still very difficult) to write useful Malbolge programs.

## Programming in Malbolge

Malbolge was so difficult to understand when it arrived that it took two years for the first Malbolge program to appear. Indeed, the author himself has never written a single Malbolge program.[1] The first program was not written by a human being: it was generated by a beam search algorithm designed by Andrew Cooke and implemented in Lisp.[2]

Later, Lou Scheffer posted a cryptanalysis of Malbolge and provided a program to copy its input to its output.[3] He also saved the original interpreter and specification after the original site stopped functioning, and offered a general strategy of writing programs in Malbolge as well as some thoughts on its Turing-completeness.[4]

Olmstead believed Malbolge to be a linear bounded automaton. There is a discussion about whether one can implement sensible loops in Malbolge — it took many years before the first non-terminating one was introduced. A correct 99 Bottles of Beer program, which deals with non-trivial loops and conditions, was not announced for seven years; the first correct one was by Hisashi Iizawa in 2005.[5] Hisashi Iizawa et al. also propose a guide for programming in Malbolge for the purpose of the application for obfuscation in software protection.[6]

## "Hello World!" in Malbolge

This Malbolge program displays "Hello World!", with both words capitalized and exclamation mark at the end.

 ('&amp;%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@&amp;gt;}=&amp;lt;M:9wv6WsU2T|nm-,jcL(I&amp;%$#"
CB]V?Tx&amp;lt;uVtTRpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@&amp;gt; A significantly shorter version:  (=&amp;lt;#9]~6ZY32Vx/4Rs+0No-&amp;Jk)"Fh}|Bcy?=*z]Kw%oG4UUS0/@-ejc(:'8dc Another sample program which produces "Hello, world.":  (=&amp;lt;:9876Z4321UT.-Q+*)M'&amp;%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk**
hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O&amp;lt;

Yet another showing with scrambled lower and upper cases "HEllO WORld"

#### Method 2

Find the result below. Store the encrypted version at [c].

Encryption table
Result Encrypted Result Encrypted Result Encrypted Result Encrypted Result Encrypted
0 57 19 108 38 113 57 91 76 79
1 109 20 125 39 116 58 37 77 65
2 60 21 82 40 121 59 92 78 49
3 46 22 69 41 102 60 51 79 67
4 84 23 111 42 114 61 100 80 66
5 86 24 107 43 36 62 76 81 54
6 97 25 78 44 40 63 43 82 118
7 99 26 58 45 119 64 81 83 94
8 96 27 35 46 101 65 59 84 61
9 117 28 63 47 52 66 62 85 73
10 89 29 71 48 123 67 85 86 95
11 42 30 34 49 87 68 33 87 48
12 77 31 105 50 80 69 112 88 47
13 75 32 64 51 41 70 74 89 56
14 39 33 53 52 72 71 83 90 124
15 88 34 122 53 45 72 55 91 106
16 126 35 93 54 90 73 50 92 115
17 120 36 38 55 110 74 70 93 98
18 68 37 103 56 44 75 104

#### Cycles in the encryption

Lou Scheffer's cryptanalysis of Malbolge mentions six different cycles in the encryption. They are listed here:

• 33 ⇒ 53 ⇒ 45 ⇒ 119 ⇒ 78 ⇒ 49 ⇒ 87 ⇒ 48 ⇒ 123 ⇒ 71 ⇒ 83 ⇒ 94 ⇒ 57 ⇒ 91 ⇒ 106 ⇒ 77 ⇒ 65 ⇒ 59 ⇒ 92 ⇒ 115 ⇒ 82 ⇒ 118 ⇒ 107 ⇒ 75 ⇒ 104 ⇒ 89 ⇒ 56 ⇒ 44 ⇒ 40 ⇒ 121 ⇒ 35 ⇒ 93 ⇒ 98 ⇒ 84 ⇒ 61 ⇒ 100 ⇒ 97 ⇒ 46 ⇒ 101 ⇒ 99 ⇒ 86 ⇒ 95 ⇒ 109 ⇒ 88 ⇒ 47 ⇒ 52 ⇒ 72 ⇒ 55 ⇒ 110 ⇒ 126 ⇒ 64 ⇒ 81 ⇒ 54 ⇒ 90 ⇒ 124 ⇒ 34 ⇒ 122 ⇒ 63 ⇒ 43 ⇒ 36 ⇒ 38 ⇒ 113 ⇒ 108 ⇒ 39 ⇒ 116 ⇒ 69 ⇒ 112 ⇒ 68 ⇒ 33 ...
• 37 ⇒ 103 ⇒ 117 ⇒ 111 ⇒ 120 ⇒ 58 ⇒ 37 ...
• 41 ⇒ 102 ⇒ 96 ⇒ 60 ⇒ 51 ⇒ 41 ...
• 42 ⇒ 114 ⇒ 125 ⇒ 105 ⇒ 42 ...
• 50 ⇒ 80 ⇒ 66 ⇒ 62 ⇒ 76 ⇒ 79 ⇒ 67 ⇒ 85 ⇒ 73 ⇒ 50 ...
• 70 ⇒ 74 ⇒ 70 ...

These cycles can be used to create loops that do different things each time and that eventually become repetitive. Lou Scheffer used this idea to create a Malbolge program (included in his cryptanalysis linked below) that repeats anything the user inputs.

## Variants

Malbolge is not Turing-complete, due to its memory limits. However, it otherwise has sequential execution, repetition, and conditional-execution. Several attempts have been made to create Turing-complete versions of Malbolge:

• Malbolge-T is a theoretical version of Malbolge that resets the input/output stream upon reaching the end, allowing for unbounded programs. Malbolge-T would be backward compatible with Malbolge.[9]
• Malbolge Unshackled is a hopefully Turing-complete variation, allowing for programs of any length. However, due to command variations to allow for values above 257, valid Malbolge programs will not necessarily run correctly in Malbolge Unshackled.[10]

## Popular culture

In the television series Elementary, during the episode "Leviathan" (season 1, ep.10), a clue written on a coffee order is described as having been written in Malbolge. It appears to be a small modification of the more verbose "Hello World" example shown above.[1][11]

## References

1. Temkin, Daniel (3 November 2014). "Interview with Ben Olmstead".
2. "andrew cooke: malbolge "hello world""
3. Programming in Malbolge. Lscheffer.com (2007-12-11).
4. "Malbolge - Progopedia - Encyclopedia of Programming Languages". progopedia.com.
5. "Language Malbolge". 99 Bottles of Beer.
6. IIZAWA, Hisashi. "http://www.sakabe.i.is.nagoya-u.ac.jp/~nishida/DB/pdf/iizawa05ss2005-22.pdf" (PDF). www.sakabe.i.is.nagoya-u.ac.jp (in Japanese). Graduate School of Information Science, Nagoya University Furo-cho, Chikusa-ku, Nagoya City, Aichi, 464–8603 Japan.
7. Green, Austin. "Malbolge". www2.latech.edu.
8. Olmstead, Ben (1998). "Malbolge Specification". www.lscheffer.com.
9. Scheffer, Lou. "Programming in Malbolge". www.lscheffer.com.
10. Malbolge Unshackled – Esolang. Esolangs.org (2010-11-24).
11. "Leviathan". Elementary. Season 1. Episode 10.