THESE FORUMS NOW CLOSED (read only)

Fun Stuff => CLIKC => Topic started by: pwhodges on 07 Jan 2014, 14:58

Title: A programming challenge (j/k)
Post by: pwhodges on 07 Jan 2014, 14:58
Malbolge (https://en.wikipedia.org/wiki/Malbolge) is a programming language designed to be impossible to write a program in.  It failed in this aim, because after a mere two years, someone managed to produce a meaningful program (not manually, even then); it took seven years, however, before a "99 bottles of beer" program (http://www.99-bottles-of-beer.net/language-malbolge-995.html) was managed (and it's not actually a loop, but just lists the output required). 

The Malbolge machine is ternary, just to get you started, and: "Malbolge figures out which instruction to execute by taking the value at [c], adding the value of c to it, and taking the remainder when this is divided by 94", where c is the instruction pointer, [c] being the location pointed to.  Also: "After each instruction is executed, the guilty instruction gets encrypted (see below) so that it won't do the same thing next time" - which makes writing loops tricky!

Here are two "Hello World!" programs written in Malbolge:

Code: [Select]
('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=<M:9wv6WsU2T|nm-,jcL(I&%$#"
`CB]V?Tx<uVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>

Code: [Select]
(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc
A more detailed (http://www.lscheffer.com/malbolge.shtml) description.  I am not suggesting that anyone really tries to write a program in this, nor even tries to work out how one of those programs works!

(This post could just as well have gone in the pointless thread, but it's technical nature belongs here.)
Title: Re: A programming challenge (j/k)
Post by: cesium133 on 07 Jan 2014, 15:01
Thinking of esoteric programming languages, somewhere on my hard drive I have a Shakespeare program that sets up a subroutine call system. The return address is stored by telling an act number to Hamlet and a scene number to Horatio.
Title: Re: A programming challenge (j/k)
Post by: snalin on 08 Jan 2014, 04:02
I wrote an interpreter for Befunge (http://esolangs.org/wiki/Befunge#Language_overview) for a compiler course this last semestre. It's a lot less complicated than many others, but it's still really, really hard to write code that does something sensible for it. 99 bottles should not be too hard, gcd would be much worse.
Title: Re: A programming challenge (j/k)
Post by: ankhtahr on 08 Jan 2014, 05:33
For some reason I really enjoy Brainfuck.

But yeah, the SPL is pretty awesome too.
Title: Re: A programming challenge (j/k)
Post by: snalin on 08 Jan 2014, 05:40
Okay, dammit, I made a gcd for befunge. You can see how it works on the brilliant playground (not made by me, just to be clear) here (http://www.bedroomlan.org/tools/befunge-93-playground). Just paste the code into the box, select "input code and reset", and then "run". You'll be prompted to enter two numbers, and the output should be their greatest common divisor.

Code: [Select]
>" regetni tsrif tupni">:v     < storage cell       v,_ $&  v input on line 1,2
                       ^,_ &0" regetni dnoces tupni">:^

>                               v                           <
^ \ g 0 * 5 6 % p 0 * 5 6 : <
                            | : < algorithm on lines 4,5,6,7
    @.,,,,,,,, "output: " $ <

The playground shows you what the stack is at any time, and what symbol the program pointer is at. It's a pretty cool feature, and debugging the stuff without something like that is a nightmare.
Title: Re: A programming challenge (j/k)
Post by: Edguy on 08 Jan 2014, 08:57
(http://i608.photobucket.com/albums/tt167/michaelismyname/neeerds.jpg)

#Goes away to play LoL, read webcomics or work on my engineering studies.*