« Halloween Theme | Main | J.D. Power Comes A-Calling »

November 01, 2005

Obfuscated Monad Script

OK, what does this script do?

$s = "a*h*t*s*m*i*d*o*n*l*k*e*y*u*g*r*w*CBAC> DAE-F-AE>!<R S!><" +
    "F GH IHC> JFKL> T<<GH MHN> V+ OPLLI LOOD AIG BAE>?<" +
    "U V+ CBLE>, S.<U V X><<QHNJG MHN> V Y> BLPL HP CBLPL>?<" +
    "F QHNJG IHC> \ ]>.<^ \> AIMQBLPL>.<Z.<U \>, S.<<" +
    "[ \> FI A BHNDL>?<c+ QFCB A EHNDL>?<b d>.<b e>.<b ]>.<b a><Z.<b, S>.<"
$cur = ""
$line = ""
[char]$next = "A"
$store = @{}
foreach ($c in [char[]]$s) {
    switch -regex ($c) {
        "[\*\>]" {
            $store[$next] = $cur.TrimStart(" ")
            $next = [char]([int]$next + 1)
            if ($c -eq ">") { $line += $cur }
            $cur = ""
        }
        "\+" {
            $line += $cur
            $cur = ""
        }
        "\<" {
            $line + $cur
            $line = ""
            $cur = ""
        }
        default {
            if ($store.Contains($c)) {
                $cur += $store[$c]
            } else {
                $cur += $c
            }
        }
    }
}

I'm not (really) expecting anyone to figure it out from the code...just run it and be shocked and awed.

Posted by AdamBa at November 1, 2005 11:39 AM

Trackback Pings

TrackBack URL for this entry:
http://proudlyserving.com/cgi-bin/mt-tb.cgi/357

Comments

LOL! That's a good one - I definitely didn't expect anything like that for the output. :)

Posted by: Andy at November 1, 2005 02:20 PM

Holy crap.

Posted by: Nick at November 1, 2005 10:12 PM

OK!! Someone has to much time on their hands!! :D

Posted by: Ken at November 2, 2005 07:33 AM

I recognize the code as a decompression algorithm, but I'm not about to try to run it in my head to predict the output. do you have the code that built the big string up top?

Posted by: Wolf Logan at November 2, 2005 03:13 PM

I did it by hand.

Anyone want to volunteer to add some more?

- adam

Posted by: Adam Barr at November 2, 2005 03:37 PM

Did you mean Occulted Monad Script ??

http://www.excludedmiddle.com/occulted_dr._seuss.htm

gr /\/\o\/\/

Posted by: /\/\o\/\/ at November 2, 2005 03:53 PM

Not knowing Monad, I decided to work this out by hand. With a few educated guesses I got it working. Very nice still script, it's impresive what you can do with the language.

Posted by: Fox Cutter at November 3, 2005 09:49 AM