The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Speed Challenge 12

Last post 05-10-2007 4:56 AM by Faxmachinen. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 05-07-2007 6:04 AM

    • flop
    • Top 500 Contributor
    • Joined on 04-27-2007
    • Posts 51

    Speed Challenge 12

    So here's somethink easier, though alike in spirit:

     Write a program, that writes a program, that writes ... all in different languages. Shell, PHP, Java, Perl, Javascript, C, Python, ...

    A small example - writing HTML from Javascript from PHP:

    <?php 
    echo '<HTML><BODY><SCRIPT language=javascript>',
    'document.write("<B>WTF</b>");',
    </SCRIPT></BODY></HTML>';
    ?>

     I'd say that the points given are calculated by (Number of languages involved)/(Bytes of Source).
     

    Endtime is 12:00 GMT on May 8th.
    Filed under: ,
  • 05-07-2007 6:16 PM In reply to

    Re: Speed Challenge 12

    Well I couldn't get the only Chef interpreter ever made to compile, so I have no idea if the later stages of this thing works. Anyhow, it features a Python string-to-brainfuck encoder, one of the longest one-liners in Perl ever, and a Chef recipe for a very simple MSDOS shell script ("echo WTF").
    Obviously I didn't aim for the lowest character-per-language ratio.
     
    # makebrainfuck.py
     
    perl = 'print "Whole Trout Fromage.\\n\
    \\n\
    Ingredients.\\n\
    \\t17 tablespoons wheat flour\\n\
    \\t1 trout\\n\
    \\t70 fried onion rings\\n\
    \\t32 slices of parsnip\\n\
    \\t2 pinches estragon\\n\
    \\t99 cherries\\n\
    \\t5 hungarian beans\\n\
    \\t15 ml olive oil\\n\
    \\t83 g sugar\\n\
    \\t3 eggs\\n\
    \\n\
    Pre-heat oven to 200 degrees Celcius.\\n\
    \\n\
    Method.\\n\
    Put fried onion rings into the mixing bowl. Add wheat flour.\\n\
    Put sugar into the mixing bowl. Add trout. Stir for 1 minute.\\n\
    Fold sugar into the mixing bowl. Stir for 1 minute.\\n\
    Put slices of parsnip into the mixing bowl. Combine eggs into the mixing bowl.\\n\
    Add olive oil. Stir for 1 minute. Fold olive oil into the mixing bowl.\\n\
    Put cherries into the mixing bowl. Add hungarian beans. Stir for 1 minute.\\n\
    Add estragon to the mixing bowl.\\n\
    Pour the contents of the mixing bowl into the baking dish.\\n\
    \\n\
    Serves 1.\\n";'
     
    brainfuck = ["makeperl_b\n>"]
    memsize = 0
    for ch in perl:
        charval = ord(ch)
        for i in range(charval):
            brainfuck.append('+')
        brainfuck.append('\n>')
        memsize += 1
    brainfuck.append('<[<]>[.>]')
    out = open("makeperl.b", 'w+')
    out.write("".join(brainfuck))
    out.close()
    rpar PROTON all
    Filed under: , , , ,
  • 05-07-2007 7:30 PM In reply to

    Re: Speed Challenge 12

    Scary, I've actually done something similar to this in a serious project.

    A somewhat boring (uses relatively well-known languages) solution.  The shell script creates chain.c through echos, compiles it and runs it with BrainF*ck input.  chain takes the input and creates Python code which turns the BF into the equivalent Perl.  The result of the Perl is jammed back into chain which creates the HTML/javascript.

    http://omega0.xepher.net/stuff/chain.txt

    (BTW, what is this board's tag for code formatting? I tried [ code ] which didn't seem to do anything but turn the code into a mess of HTML markup)
  • 05-07-2007 9:41 PM In reply to

    Re: Speed Challenge 12

    I use QUOTE tags, actually. Funny how this is the only forum of those I visit where the CODE tags are broken.
    rpar PROTON all
    Filed under:
  • 05-08-2007 3:50 AM In reply to

    Re: Speed Challenge 12

    omega0:
    Scary, I've actually done something similar to this in a serious project.


    Please stop. Especially if it's this one:

    # This header file was automatically generated by itself.
    # (Yup, it's a C++ header file and a perl script.)

    (There are several variants of that bastard around, I can't recall which one was the original. STOP USING IT)
     

  • 05-08-2007 3:54 AM In reply to

    Re: Speed Challenge 12

    Faxmachinen:
    I use QUOTE tags, actually. Funny how this is the only forum of those I visit where the CODE tags are broken.

    Leave a couple of blank lines while you write the rest of your post. When you're done, whack the "HTML" button. Manually enter a <pre> and </pre> in the space. Paste the code between them. Hit "Update". In the stupid rich text editor, it will not look right. The rich text editor is wrong. It will look right after you post it. Yes, this is retarded.

    Anything else will likely render your code in a variable-width font, and that just sucks. 

  • 05-08-2007 8:24 AM In reply to

    • flop
    • Top 500 Contributor
    • Joined on 04-27-2007
    • Posts 51

    Re: Speed Challenge 12

    There's only one real try ... so it's Faxmachinens turn.
  • 05-08-2007 9:29 AM In reply to

    Re: Speed Challenge 12

    Out of curiosity - if we stick to the languages/bytes criterion, and assume that the innermost program has to write 'wtf', does anyone know of a better solution than '?"wtf"' (APL writing dBase)?
  • 05-10-2007 4:56 AM In reply to

    Re: Speed Challenge 12

    Oops, forgot to post in this thread. New challenge is up.
    rpar PROTON all
Page 1 of 1 (9 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems